import sys from collections import deque, Counter sys.setrecursionlimit(5 * 10 ** 5) from pypyjit import set_param set_param('max_unroll_recursion=-1') input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n, k = mi() a = list(range(1, n + 1)) k = sum(a) - k right = 0 #n -> 数列の長さ s = 0 ans = 2 for left in range(n): while right < n: s += a[right] if s <= k: right += 1 else: s -= a[right] break if s == k: ans = 1 if right == left: right += 1 else: s -= a[left] print(ans)