#include using namespace std; int main() { int n, k; cin >> n >> k; int sm = (n * (n + 1)) / 2; long long diff1 = sm - k, diff2 = sm - k; int F[n], B[n], i; set stf, stb; for(i = 0; i < n; i++) { F[i] = ((i + 1) * (i + 2)) / 2; B[n - i - 1] = (n * (n + 1)) / 2 - ((i + 2) * (i + 1)) / 2; stf.insert(F[i]); stb.insert(B[n - i - 1]); } int front = 0, back = 0; if(k == 0) { front = 1; back = 1; } else { for(i = 0; i < n; i++) { if(diff1 >= F[i]) { diff1 -= F[i]; } else { diff1 -= F[i]; diff1 = abs(diff1); if(stf.find(diff1) == stf.end()) front = 2; else front = 1; break; } } for(i = n - 1; i >= 0; i--) { if(diff2 >= B[i]) { diff2 -= B[i]; } else { diff2 -= B[i]; diff2 = abs(diff2); if(stb.find(diff2) == stb.end()) back = 2; else back = 1; break; } } } if(front == 1 || back == 1) cout << 1 << endl; else cout << 2 << endl; return 0; }