#########################################################
#                                                       #
#    Coded by Indranil Ghosh (indranilg49@gmail.com)    #     
#                                                       #
#########################################################

#Python 2.7.11, OEIS sequence: A057164

from sympy import floor, binomial, factorial as f

def ok(n):
    if n==0: return 1
    B=bin(n)[2:] if n!=0 else '0'
    s=0
    for b in B:
        s+=1 if b=='1' else -1
        if s<0: return False
    return s==0

def a036044(n): return 1 if n==0 else int((''.join('1' if i == '0' else '0' for i in bin(n)[2:]))[::-1], 2)

def a080166(n):
    l=0
    while n>0:
        l+=(-1)**n
        if l<0: return 0
        n=floor(n/2)
    return 0 if l>0 else 1

def a030101(n): return int(bin(n)[2:][::-1], 2)

def a014137(n): return sum([f(2*k)/((f(k))**2*(k + 1)) for k in xrange(n + 1)])

def a215406(n): 
    m=floor(len(bin(n)[2:])/2)
    A=a030101(n)
    y=0
    t=1
    for x in xrange(1, 2*m):
        u=2*m - x
        v=m - (x + y + 1)/2
        mn=binomial(u, v) - binomial(u, v - 1)
        t+=mn*(1 - A%2)
        y-=(-1)**A
        A=floor(A/2)
    return a014137(m) - t

def a080300(n): return a080166(n)*a215406(n)

print [a080300(a036044(n)) for n in xrange(4001) if ok(n)]