import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!long);
    auto X = s[0];
    auto Y = s[1];
    long[long] D;

    for (long i = 0; i * i <= Y; ++i) {
        for (long j = i; i * i + j * j <= Y; ++j) {
            D[i * i + j * j] += i == j || i == 0 ? 4 : 8;
        }
    }

    if (Y !in D) D[Y] = 0;
    D.keys.filter!(k => X <= k && k <= Y).map!(k => D[k]).reduce!max.writeln;
}