import numpy as np def hantei(R): return np.sqrt(R)==int(np.sqrt(R)) X,Y =map(int,input().split()) l =[0]*(Y-X+1) for i in range(int(np.sqrt(Y))+1): for j in range(i+1): if X <= i**2 +j**2 <= Y: l[i**2 +j**2-X] +=8 for i in range(X,Y+1): if hantei(i) or hantei(i/2): l[i-X] -= 4 print(max(l))