import math def main(): import sys input = sys.stdin.read().split() N = int(input[0]) K = int(input[1]) S = N * (N + 1) // 2 D = S - K if D == 0: print(0) return def check_single(): max_k = int(math.isqrt(2 * D)) + 1 for k in range(1, max_k + 1): if (2 * D) % k != 0: continue temp = (2 * D) // k numerator = temp - k + 1 if numerator <= 0: continue if numerator % 2 != 0: continue a = numerator // 2 b = a + k - 1 if a >= 1 and b <= N: return True return False if check_single(): print(1) else: print(2) if __name__ == "__main__": main()