n,k=map(int,input().split()) s=2 for i in range(1,n+1): x=(n-i)*(n+i+1)//2-k if x<0: break if x>i*(n-i): continue if x%i==0: s=1 print(s)