import java.math.BigInteger;
import java.util.*;

public class Euler169 {
    static Map<BigInteger, Long> memo = new HashMap<>();

    static long f(BigInteger n) {
        if (memo.containsKey(n))
            return memo.get(n);
        long ans;
        if (n.signum() == 0)
            ans = 1;
        else if (n.signum() < 0)
            ans = 0;
        else if (n.testBit(0))
            ans = f(n.subtract(BigInteger.ONE).shiftRight(1));
        else {
            BigInteger half = n.shiftRight(1);
            ans = f(half) + f(half.subtract(BigInteger.ONE));
        }
        memo.put(n, ans);
        return ans;
    }

    public static void main(String[] args) {
        memo.put(BigInteger.ZERO, 1L);
        memo.put(BigInteger.ONE.negate(), 0L);
        System.out.println(f(BigInteger.TEN.pow(25)));
    }
}
