#pragma GCC optimize(3,"Ofast","inline") #include #define ios_close std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr) using ll = long long; using ull = unsigned long long; using i128 = __int128; #define Pi acos(-1.0); #define PINF 0x3f3f3f3f #define NINF -0x3f3f3f3f void solve(){ std::vector pre(1000010); int n; ll k; scanf("%d %lld", &n, &k); for(int i = 1; i <= n; i ++ ){ pre[i] = pre[i - 1] + i; } if(pre[n] == k){ printf("0"); return ; } std::unordered_set S; S.insert(0); ll t = k - pre[n]; for(int i = 1; i <= n; i ++ ){ if(S.count(t + pre[i])){ printf("1"); return ; } S.insert(pre[i]); } printf("2"); } int main(){ #if 0 ios_close; #endif #if 0 freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif int T = 1; #if 0 std::cin >> T; #endif while(T -- ){ solve(); } return 0; }