#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  N %= 3;
  if (N == 0){
    cout << 0 << endl;
  } else {
    cout << (N ^ 3) << endl;
  }
}