R,B = map(int,input().split()) l = 1 r = 2000000 while r - l > 1: k = (l + r) // 2 s = k*(k+1)*(2*k+1) // 6 f = 0 RR,BB = R,B for kk in range(k,0,-1): if RR >= kk*kk: RR -= kk*kk s -= kk*kk if s <= BB: f = 1 s = k*(k+1)*(2*k+1) // 6 RR,BB = B,R for kk in range(k,0,-1): if RR >= kk*kk: RR -= kk*kk s -= kk*kk if s <= BB: f = 1 if f: l = k else: r = k print(l)