import java.util.*;

public class Euler342 {

    static class Solver {
        long limit_exclusive;
        int max_prime;

        List<Integer> primes_desc = new ArrayList<>();
        int[] spf;
        List<List<int[]>> factorsMod3OfPMinus1;
        byte[] residueMod3;
        List<Integer> includedPrimes = new ArrayList<>();
        long answer = 0;

        Solver(long limit) {
            this.limit_exclusive = limit;
            this.max_prime = (int) Math.sqrt(limit - 1);
        }

        void buildPrimesAndSpf() {
            spf = new int[max_prime + 1];
            for (int i = 0; i <= max_prime; i++)
                spf[i] = i;

            for (int i = 2; i <= Math.sqrt(max_prime); i++) {
                if (spf[i] != i)
                    continue;
                for (int j = i * i; j <= max_prime; j += i) {
                    if (spf[j] == j)
                        spf[j] = i;
                }
            }

            List<Integer> primesAsc = new ArrayList<>();
            for (int i = 2; i <= max_prime; i++) {
                if (spf[i] == i)
                    primesAsc.add(i);
            }

            for (int i = primesAsc.size() - 1; i >= 0; i--) {
                primes_desc.add(primesAsc.get(i));
            }

            factorsMod3OfPMinus1 = new ArrayList<>(max_prime + 1);
            for (int i = 0; i <= max_prime; i++) {
                factorsMod3OfPMinus1.add(new ArrayList<>());
            }

            for (int p : primesAsc) {
                int x = p - 1;
                List<int[]> vec = factorsMod3OfPMinus1.get(p);
                while (x > 1) {
                    int q = spf[x];
                    int cnt = 0;
                    while (x % q == 0) {
                        x /= q;
                        cnt++;
                    }
                    cnt %= 3;
                    if (cnt != 0) {
                        vec.add(new int[] { q, cnt });
                    }
                }
            }

            residueMod3 = new byte[max_prime + 1];
        }

        void applyFactors(int p, int sign) {
            for (int[] factor : factorsMod3OfPMinus1.get(p)) {
                int q = factor[0];
                int e = factor[1];
                int v = residueMod3[q];
                if (sign > 0) {
                    v += e;
                } else {
                    v -= e;
                }
                v %= 3;
                if (v < 0) {
                    v += 3;
                }
                residueMod3[q] = (byte) v;
            }
        }

        long multiplierSumRec(int pos, long remaining) {
            if (pos == includedPrimes.size())
                return 1;

            long p = includedPrimes.get(pos);
            long p3 = p * p * p;

            long total = 0;
            long mul = 1;

            while (mul <= remaining) {
                long next_remaining = remaining / mul;
                total += mul * multiplierSumRec(pos + 1, next_remaining);

                if (mul > remaining / p3)
                    break;
                mul *= p3;
            }
            return total;
        }

        void addSolution(long baseN) {
            if (baseN <= 1 || baseN >= limit_exclusive)
                return;
            long remaining = (limit_exclusive - 1) / baseN;
            long mulSum = multiplierSumRec(0, remaining);
            answer += baseN * mulSum;
        }

        void dfs(int idx, long currentN) {
            while (true) {
                int i = idx;
                int npr = primes_desc.size();

                while (i < npr) {
                    int p = primes_desc.get(i);
                    int c = residueMod3[p];
                    if (c != 0)
                        break;

                    long minInclude = (long) p * p;
                    // If it overflows limit_exclusive or equals it, we just continue loop to
                    // exclude it
                    // Using BigInteger or just division to check overflow
                    if (currentN < limit_exclusive / minInclude + 1) { // currentN * minInclude < limit
                        // Need to check exact currentN * minInclude < limit
                        long product = currentN * minInclude;
                        if (currentN != 0 && product / currentN == minInclude && product < limit_exclusive) {
                            break;
                        }
                    }
                    i++;
                }

                if (i >= npr) {
                    addSolution(currentN);
                    return;
                }

                int p = primes_desc.get(i);
                int c = residueMod3[p];

                if (c == 0) {
                    long power = (long) p * p;
                    if (currentN < limit_exclusive / power + 1) {
                        long product = currentN * power;
                        if (currentN != 0 && product / currentN == power && product < limit_exclusive) {
                            applyFactors(p, +1);
                            includedPrimes.add(p);
                            dfs(i + 1, product);
                            includedPrimes.remove(includedPrimes.size() - 1);
                            applyFactors(p, -1);
                        }
                    }
                    idx = i + 1;
                    continue;
                }

                int m = (2 + c) % 3;
                int e0 = (m == 0) ? 3 : m;
                long power = 1;
                for (int j = 0; j < e0; j++)
                    power *= p;

                if (currentN >= limit_exclusive / power + 1)
                    return;
                long product = currentN * power;
                if (currentN != 0 && product / currentN != power)
                    return;
                if (product >= limit_exclusive)
                    return;

                applyFactors(p, +1);
                includedPrimes.add(p);
                dfs(i + 1, product);
                includedPrimes.remove(includedPrimes.size() - 1);
                applyFactors(p, -1);
                return;
            }
        }

        long solve() {
            buildPrimesAndSpf();
            answer = 0;
            includedPrimes.clear();
            dfs(0, 1L);
            return answer;
        }
    }

    public static String solve() {
        Solver solver = new Solver(10000000000L);
        long ans = solver.solve();
        return String.valueOf(ans);
    }

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