#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 10;
int n, x, a[6][3] = {{0, 1, 2}, {1, 0, 2}, {1, 2, 0},
                     {2, 1, 0}, {2, 0, 1}, {0, 2, 1}};
int main() {
  cin >> n >> x;
  cout << a[n % 6][x];
  return 0;
}
