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