import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) import math import bisect #import itertools #import random #from heapq import heapify, heappop, heappush from collections import defaultdict from collections import deque #import copy #DeepCopy: hoge = [_[:] for _ in hogehoge] #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] def main(): N,K = map(int,input().split()) x = N*(N+1)//2 - K L = make_divisors(x*2) # print(L) for p in L: q = x//p # print(p,q) if (p-q+1)%2 == 1: continue if (p+q-1)%2 == 1: continue a = (p-q+1)//2 b = (p+q-1)//2 # print(a,b) if 0 <= a < b <= N: exit(print(1)) print(2) if __name__ == '__main__': main()