while True:
    try:
        s = int(input())
        l = []
        for i in range(s+1):
            sum = 0
            for j in range(1,i+1): # 除数要从1开始,不能从0开始
                if i % j == 0 and j != i:
                    sum += j
                else:
                    continue
            if sum == i and sum != 0:
                l.append(i)
            else:
                continue
        print(len(l))
    except:
        break