N, K = map(int, input().split()) S, SS = set(), set() for i in range(N + 1): S.add(i * (i + 1)//2) SS.add(N * (N + 1)//2 - i * (i + 1)//2) for s in S: if K - s in SS: print(1) exit() print(2)