r, b = map(int, input().split()) t = r + b if r > b: r, b = b, r l_ = 0 r_ = t + 1 while r_ - l_ > 1: m = (l_ + r_) // 2 if m * (m + 1) * (2 * m + 1) // 6 <= t: l_ = m else: r_ = m m = l_ tt = l_ * (l_ + 1) * (2 * l_ + 1) // 6 dp = [1] x = min(m, 100) for x in range(1, x + 1): t = x * x dp += [0] * t for i in range(len(dp) - 1, t - 1, -1): dp[i] |= dp[i - t] if r > len(dp): print(m) exit() if m > 100: for i in range(200, len(dp)): dp[i] = 1 while r + b > tt and not dp[r]: r -= 1 if dp[r]: print(m) else: print(m - 1)