import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Euler834 {

    static int[] buildSpf(int n) {
        int[] spf = new int[n + 1];
        for (int i = 0; i <= n; ++i)
            spf[i] = i;
        for (int i = 2; (long) i * i <= n; ++i) {
            if (spf[i] == i) {
                for (int j = i * i; j <= n; j += i) {
                    if (spf[j] == j)
                        spf[j] = i;
                }
            }
        }
        return spf;
    }

    static void factorWithSpf(int x, int[] spf, HashMap<Long, Integer> fac) {
        while (x > 1) {
            int p = spf[x];
            int e = 0;
            while (x % p == 0) {
                x /= p;
                ++e;
            }
            long pLong = p;
            fac.put(pLong, fac.getOrDefault(pLong, 0) + e);
        }
    }

    static class Pair {
        long p;
        int e;

        Pair(long p, int e) {
            this.p = p;
            this.e = e;
        }
    }

    static void dfs(int idx, long cur, ArrayList<Pair> pf, int t, int n, long[] ans) {
        if (idx == pf.size()) {
            if (cur > n) {
                ans[0] += (cur - n);
            }
            long d2 = cur << t;
            if (d2 > n) {
                ans[0] += (d2 - n);
            }
            return;
        }

        Pair p = pf.get(idx);
        long v = 1;
        for (int k = 0; k <= p.e; ++k) {
            dfs(idx + 1, cur * v, pf, t, n, ans);
            v *= p.p;
        }
    }

    static long TValue(int n, int[] spf) {
        int a = n;
        int b = n - 1;

        int t = 0;
        while ((a & 1) == 0) {
            a >>= 1;
            ++t;
        }
        while ((b & 1) == 0) {
            b >>= 1;
            ++t;
        }

        HashMap<Long, Integer> fac = new HashMap<>();
        factorWithSpf(a, spf, fac);
        factorWithSpf(b, spf, fac);

        ArrayList<Pair> pf = new ArrayList<>();
        for (Map.Entry<Long, Integer> entry : fac.entrySet()) {
            pf.add(new Pair(entry.getKey(), entry.getValue()));
        }

        long[] ans = new long[1];
        dfs(0, 1, pf, t, n, ans);
        return ans[0];
    }

    static long UValue(int N) {
        int[] spf = buildSpf(N);
        long total = 0;
        for (int n = 3; n <= N; ++n) {
            total += TValue(n, spf);
        }
        return total;
    }

    public static String solve() {
        return Long.toString(UValue(1234567));
    }

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