#include #include #define llint long long #define mod 1000000007 using namespace std; llint p, n; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> p >> n; if(n == 1){ cout << 0 << endl; return 0; } if(p == 2){ cout << 0 << endl; return 0; } if(p%4 == 3) cout << 1 << endl; else cout << 0 << endl; return 0; }