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