#include <bits/stdc++.h>
int n, m, a[6][3] = {{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", a[n % 6][m]);
  return 0;
}
