N,K = map(int, input().split()) all = N*(N+1)//2 U = set() D = set() for i in range(1,N+1): v = i*(i+1)//2 U.add(v) D.add(all-v) for u in U: if K-u in D: print(1) exit() print(2)