from collections import * X, Y = map(int, input().split()) L = [] D = [0] * (10 ** 7 + 5) i = 1 while i * i <= Y: L.append(i * i) D[i * i] += 1 i += 1 for a in L: for b in L: if X <= a + b <= Y: D[a + b] += 1 ans = 0 # print("test", len(D)) # for k, v in D.items(): # if X <= k <= Y: # ans = max(ans, v) for i in range(X, Y + 1): ans = max(ans, D[i]) print(ans * 4)