#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const int maxn = 500050;
using namespace std;
int pos[3][11];
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  pos[0][0] = 0;
  pos[0][1] = 1;
  pos[0][2] = 2;
  pos[0][3] = 2;
  pos[0][4] = 1;
  pos[0][5] = 0;
  pos[1][0] = 1;
  pos[1][1] = 0;
  pos[1][2] = 0;
  pos[1][3] = 1;
  pos[1][4] = 2;
  pos[1][5] = 2;
  pos[2][0] = 2;
  pos[2][1] = 2;
  pos[2][2] = 1;
  pos[2][3] = 0;
  pos[2][4] = 0;
  pos[2][5] = 1;
  if (pos[0][n % 6] == k)
    cout << 0 << endl;
  else if (pos[1][n % 6] == k)
    cout << 1 << endl;
  else
    cout << 2 << endl;
}
