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