def f(R, B): dp = [0 for _ in range(R + 1)] dp[0] = 1 k = 1 z = 0 while True: flag = False ndp = [0 for _ in range(R + 1)] dp, ndp = ndp, dp for i in range(R + 1): if ndp[i] == 0: continue j = z - i if i + k**2 <= R and j <= B: dp[i + k**2] = 1 flag = True if i <= R and j + k**2 <= B: dp[i] = 1 flag = True if flag: z += k ** 2 k += 1 else: break return k - 1 def h(x): ok = 0 ng = 10**18 while ng - ok > 1: mid = (ok + ng) // 2 if mid * (mid + 1) * (2 * mid + 1) // 6 <= x: ok = mid else: ng = mid return ok R, B = map(int, input().split()) if R > B: R, B = B, R if R < 128: print(f(R, B)) else: print(h(R + B))