import java.math.BigInteger;

public class Euler360 {

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

    static class FactorTables {
        boolean[] bad;
        byte[] e5;
        int[] f1;
    }

    static FactorTables buildFactorTables(int limit, int[] spf) {
        FactorTables t = new FactorTables();
        t.bad = new boolean[limit + 1];
        t.e5 = new byte[limit + 1];
        t.f1 = new int[limit + 1];

        for (int n = 1; n <= limit; n++) {
            int x = n;
            boolean bad = false;
            byte exp5 = 0;
            int mult = 1;

            while (x > 1) {
                int p = spf[x];
                int e = 0;
                do {
                    x /= p;
                    e++;
                } while (x % p == 0);

                if (p == 5) {
                    exp5 = (byte) e;
                } else if ((p & 3) == 3) {
                    if ((e & 1) != 0)
                        bad = true;
                } else if ((p & 3) == 1) {
                    mult *= (e + 1);
                }
            }
            t.bad[n] = bad;
            t.e5[n] = exp5;
            t.f1[n] = mult;
        }
        return t;
    }

    static BigInteger sumForRadiusPowerOfFive(int exp) {
        long r = (long) Math.pow(5, exp);
        int limit = (int) (2 * r);

        int[] spf = buildSpf(limit);
        FactorTables tables = buildFactorTables(limit, spf);

        boolean[] bad = tables.bad;
        byte[] e5 = tables.e5;
        int[] f1 = tables.f1;

        BigInteger total = BigInteger.valueOf(r).multiply(BigInteger.valueOf(6));
        BigInteger mult6 = BigInteger.valueOf(6);
        BigInteger mult4 = BigInteger.valueOf(4);

        for (long x = 1; x < r; x++) {
            int a = (int) (r - x);
            int b = (int) (r + x);

            if (bad[a] || bad[b])
                continue;

            long waysVal = 4L * f1[a] * f1[b] * (e5[a] + e5[b] + 1L);
            BigInteger ways = BigInteger.valueOf(waysVal);
            BigInteger add = BigInteger.valueOf(x).multiply(mult6).multiply(ways);
            total = total.add(add);
        }
        return total;
    }

    static BigInteger solve() {
        return sumForRadiusPowerOfFive(10).shiftLeft(10);
    }

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