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