#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans[7][4] = {{0, 1, 2}, {1, 0, 2}, {1, 2, 0},
                 {2, 1, 0}, {2, 0, 1}, {0, 2, 1}};
int main() {
  scanf("%d%d", &n, &m);
  printf("%d\n", ans[n % 6][m]);
  return 0;
}
