X,Y=map(int,input().split()) T=10**7 C=[0]*(Y+1) x=0 while x*x<=Y: y=0 while x*x+y*y<=Y: if x==y==0: C[0]+=1 elif x==0 or y==0: C[x*x+y*y]+=2 else: C[x*x+y*y]+=4 y+=1 x+=1 print(max(C[X:]))