#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a;
  a.push_back("012");
  a.push_back("102");
  a.push_back("120");
  a.push_back("210");
  a.push_back("201");
  a.push_back("021");
  cout << a[n % 6][m] << endl;
  return 0;
}
