import sys input = sys.stdin.readline n, m = map(int, input().split()) t = n * (n + 1) // 2 - m if(t == 0): print(0) exit(0) l = r = 1 s = 0 while(True): if(s == t): print(1) exit(0) elif(s < t): if(r > n): print(2) exit(0) s += r r += 1 else: s -= l l += 1