import java.math.BigInteger;
import java.util.stream.IntStream;

public class Euler410 {
    static byte[] buildDistinctPrimeCounts(int limit) {
        byte[] omega = new byte[limit + 1];
        if (limit < 2)
            return omega;

        byte[] composite = new byte[(limit >> 1) + 1];
        int root = (int) Math.sqrt(limit);

        for (int p = 3; p <= root; p += 2) {
            if (composite[p >> 1] != 0)
                continue;
            int step = p << 1;
            for (int j = p * p; j <= limit; j += step) {
                composite[j >> 1] = 1;
            }
        }

        for (int m = 2; m <= limit; m += 2) {
            omega[m]++;
        }
        for (int p = 3; p <= limit; p += 2) {
            if (composite[p >> 1] != 0)
                continue;
            for (int m = p; m <= limit; m += p) {
                omega[m]++;
            }
        }

        return omega;
    }

    static BigInteger solveF(long R, long X, byte[] omega) {
        int limit = (int) Math.min(R, X);
        if (limit == 0)
            return BigInteger.ZERO;

        int numChunks = Runtime.getRuntime().availableProcessors();
        long chunkSize = (limit + numChunks - 1) / numChunks;

        BigInteger total = IntStream.range(0, numChunks)
                .parallel()
                .mapToObj(i -> {
                    int start = (int) (i * chunkSize + 1);
                    int end = (int) Math.min((i + 1) * chunkSize, limit);

                    long sumHi = 0;
                    long sumLo = 0;

                    for (int m = start; m <= end; m++) {
                        long t = R / m;
                        long g = X / m;
                        long weight = 1L << omega[m];
                        long unit;
                        if ((m & 1) != 0) {
                            unit = 2L * t * g;
                        } else {
                            unit = t * g + ((t & 1) & (g & 1));
                        }

                        long term = weight * unit;
                        sumLo += term;
                        if (Long.compareUnsigned(sumLo, term) < 0) {
                            sumHi++;
                        }
                    }

                    BigInteger hi = BigInteger.valueOf(sumHi).shiftLeft(64);
                    BigInteger lo = BigInteger.valueOf(sumLo);
                    if (sumLo < 0) {
                        lo = lo.add(BigInteger.ONE.shiftLeft(64));
                    }
                    return hi.add(lo);
                })
                .reduce(BigInteger.ZERO, BigInteger::add);

        return total;
    }

    static String solve() {
        long r1 = 100000000L;
        long x1 = 1000000000L;
        long r2 = 1000000000L;
        long x2 = 100000000L;

        int maxLimit = (int) Math.max(Math.min(r1, x1), Math.min(r2, x2));
        byte[] omega = buildDistinctPrimeCounts(maxLimit);

        BigInteger f1 = solveF(r1, x1, omega);
        BigInteger f2;
        if (r2 == x1 && x2 == r1) {
            f2 = f1;
        } else {
            f2 = solveF(r2, x2, omega);
        }

        return f1.add(f2).toString();
    }

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