N,K=map(int,input().split()) ANS=N A=[0]*N x=K for i in range(N,0,-1): if x>=i: A[i-1]=1 x-=i count=0 for i in range(N): if A[i]==0 and (i==0 or A[i-1]==1): count+=1 ANS=min(ANS,count) A=[0]*N x=K for i in range(N,0,-1): if x>=i: A[i-1]=1 x-=i else: break for i in range(1,N+1): if x>=i and A[i-1]==0: A[i-1]=1 x-=i if x==0: count=0 for i in range(N): if A[i]==0 and (i==0 or A[i-1]==1): count+=1 ANS=min(ANS,count) print(ANS)