X,Y = map(int,input().split()) arr = [] a = 1 while a*a <= Y: arr.append(a*a) a += 1 def is_square(n): return n**0.5 == int(n**0.5) def calc(n): ret = 0 for a in arr: if n-a <= 0: break if is_square(n-a): ret += 1 if is_square(n): ret += 1 return ret * 4 ans = 0 for n in range(max(X,Y-5000),Y+1): ans = max(ans, calc(n)) print(ans)