public class Euler601 {

    static long gcd(long a, long b) {
        while (b != 0) {
            long t = a % b;
            a = b;
            b = t;
        }
        return a;
    }

    static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    static long countCongruent1(long N, long L) {
        if (N <= 2 || L == 0)
            return 0;
        long x = N - 2;
        return (L > x) ? 0 : (x / L);
    }

    static long P(int s, long N, long[] L) {
        return countCongruent1(N, L[s]) - countCongruent1(N, L[s + 1]);
    }

    public static String solve() {
        int S_MAX = 32;
        long[] L = new long[S_MAX + 1];
        L[0] = 1;
        for (int i = 1; i <= S_MAX; i++) {
            L[i] = lcm(L[i - 1], i);
        }

        long ans = 0;
        long N = 1;
        for (int i = 1; i <= 31; i++) {
            N *= 4;
            ans += P(i, N, L);
        }

        return Long.toString(ans);
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
