while 1:e,m=map(int,raw_input().split());print min((w+3)*max(2-m/~w,~w--e/2)for w in range(e))-e-m