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