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

public class Euler241 {
    static final long LIMIT = 1000000000000000000L;

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

    static BigInteger gcd(BigInteger a, BigInteger b) {
        return a.gcd(b);
    }

    static long mulMod(long a, long b, long mod) {
        return BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)).mod(BigInteger.valueOf(mod)).longValue();
    }

    static long powMod(long a, long d, long mod) {
        long r = 1;
        while (d > 0) {
            if ((d & 1) != 0)
                r = mulMod(r, a, mod);
            a = mulMod(a, a, mod);
            d >>= 1;
        }
        return r;
    }

    static boolean isPrime(long n) {
        if (n < 2)
            return false;
        long[] smallPrimes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 };
        for (long p : smallPrimes) {
            if (n == p)
                return true;
            if (n % p == 0)
                return false;
        }

        long d = n - 1;
        int s = 0;
        while ((d & 1) == 0) {
            d >>= 1;
            s++;
        }

        long[] bases = { 2L, 325L, 9375L, 28178L, 450775L, 9780504L, 1795265022L };
        for (long a : bases) {
            if (a % n == 0)
                continue;
            long x = powMod(a, d, n);
            if (x == 1 || x == n - 1)
                continue;
            boolean composite = true;
            for (int i = 1; i < s; i++) {
                x = mulMod(x, x, n);
                if (x == n - 1) {
                    composite = false;
                    break;
                }
            }
            if (composite)
                return false;
        }
        return true;
    }

    static long splitmix64(long[] x) {
        long z = (x[0] += 0x9e3779b97f4a7c15L);
        z = (z ^ (z >>> 30)) * 0xbf58476d1ce4e5b9L;
        z = (z ^ (z >>> 27)) * 0x94d049bb133111ebL;
        return z ^ (z >>> 31);
    }

    static final ThreadLocal<long[]> rngState = ThreadLocal
            .withInitial(() -> new long[] { System.nanoTime() ^ 0x9e3779b97f4a7c15L });

    static long rand(long lo, long hi) {
        long r = splitmix64(rngState.get());
        if (r < 0)
            r = ~r;
        return lo + (hi > lo ? (r % (hi - lo + 1)) : 0);
    }

    static long pollardRho(long n) {
        if ((n & 1) == 0)
            return 2;
        if (n % 3 == 0)
            return 3;

        while (true) {
            long c = rand(1, n - 1);
            long x = rand(0, n - 1);
            long y = x;
            long d = 1;

            while (d == 1) {
                x = (mulMod(x, x, n) + c) % n;
                y = (mulMod(y, y, n) + c) % n;
                y = (mulMod(y, y, n) + c) % n;
                long diff = Math.abs(x - y);
                d = gcd(diff, n);
            }
            if (d != n)
                return d;
        }
    }

    static long minFactorRec(long n) {
        if (n == 1)
            return 1;
        if (isPrime(n))
            return n;
        long d = pollardRho(n);
        return Math.min(minFactorRec(d), minFactorRec(n / d));
    }

    static long minFactor(long n) {
        if ((n & 1) == 0)
            return 2;
        return minFactorRec(n);
    }

    static class Solver {
        long limit, targetNum;
        BigInteger sum = BigInteger.ZERO;
        Map<Long, Long> minFactorCache = new HashMap<>();

        Solver(long limit, long targetNum) {
            this.limit = limit;
            this.targetNum = targetNum;
        }

        long getMinFactor(long n) {
            return minFactorCache.computeIfAbsent(n, Euler241::minFactor);
        }

        void dfs(long n, long rn, long rs) {
            // Check n * rs > limit handling overflow with BigInteger
            if (BigInteger.valueOf(n).multiply(BigInteger.valueOf(rs)).compareTo(BigInteger.valueOf(limit)) > 0)
                return;
            if (rn == rs) {
                sum = sum.add(BigInteger.valueOf(n));
                return;
            }
            if (rn < rs)
                return;
            if (rs == 1)
                return;

            long p = getMinFactor(rs);
            if (n % p == 0)
                return;

            long tmp = rs;
            int e = 0;
            while (tmp % p == 0) {
                tmp /= p;
                e++;
            }

            BigInteger pPow = BigInteger.ONE;
            BigInteger sigma = BigInteger.ONE;
            BigInteger P = BigInteger.valueOf(p);
            BigInteger Limit = BigInteger.valueOf(limit);

            for (int i = 1;; ++i) {
                if (pPow.compareTo(Limit.divide(P)) > 0)
                    break;
                pPow = pPow.multiply(P);
                sigma = sigma.add(pPow);

                if (i < e)
                    continue;

                BigInteger n2 = BigInteger.valueOf(n).multiply(pPow);
                if (n2.compareTo(Limit) > 0)
                    break;

                BigInteger rn2 = BigInteger.valueOf(rn).multiply(pPow);
                BigInteger rs2 = BigInteger.valueOf(rs).multiply(sigma);
                BigInteger g = gcd(rn2, rs2);
                rn2 = rn2.divide(g);
                rs2 = rs2.divide(g);

                if (rn2.compareTo(rs2) < 0)
                    break;

                if (n2.multiply(rs2).compareTo(Limit) > 0)
                    continue;
                dfs(n2.longValue(), rn2.longValue(), rs2.longValue());
            }
        }

        BigInteger run() {
            dfs(1, targetNum, 2);
            return sum;
        }
    }

    public static String solve() {
        List<Long> targets = new ArrayList<>();
        for (long a = 3; a <= 13; a += 2)
            targets.add(a);

        int threads = Math.min(targets.size(), Math.max(1, Runtime.getRuntime().availableProcessors()));
        ExecutorService executor = Executors.newFixedThreadPool(threads);
        List<Future<BigInteger>> futures = new ArrayList<>();

        for (long target : targets) {
            futures.add(executor.submit(() -> {
                Solver solver = new Solver(LIMIT, target);
                return solver.run();
            }));
        }

        BigInteger total = BigInteger.ZERO;
        for (Future<BigInteger> f : futures) {
            try {
                total = total.add(f.get());
            } catch (Exception e) {
            }
        }
        executor.shutdown();

        return total.toString();
    }

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