知识点:完全数以2或者28结尾。所以先判断该数是否以6或者28结尾,然后再判断是否是完全数

while True:
    try:
        n = int(input())
        pre_list = []
        res = []
        for i in range(1, n+1):
            if i % 10 == 6:
                pre_list.append(i)
            if i % 100 == 28:
                pre_list.append(i)
        for j in pre_list:
            temp = []
            for k in range(1, int(j/2)+1): # n的约数不包含本身,故其余约数不会大于n/2
                if j % k == 0:
                    temp.append(k)
            if sum(temp) == j:
                res.append(j)
        print(len(res))
    except:
        break