#include <bits/stdc++.h>   using namespace std;   int main() {     int z[6] = {1, 0, 0, 1, 2, 2};     int r[6] = {2, 2, 1, 0, 0, 1};     int l[6] = {0, 1, 2, 2, 1, 0};     long long int m, n, num;     while (cin >> m >> n) {       num = m % 6;       if (z[num] == n) {         cout << 1 << endl;       } else if (r[num] == n) {         cout << 2 << endl;       } else {         cout << 0 << endl;       }     }     return 0;   }   