#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); ll N,K; cin >> N >> K; if(K == 0) { cout << 1 << endl; return 0; } K = N * (N + 1) / 2 - K; // x(2y+x-1) = 2K for(ll x = 1; x <= N; x++) { if((2 * K) % x == 0) { // 2y = 2K/x - x + 1 ll z = (2 * K) / x - x + 1; if(z % 2 == 0) { ll y = z / 2; if(x * (2 * y + x - 1) == 2 * K && x + y <= N) { cout << 1 << endl; return 0; } } } } cout << 2 << endl; return 0; }