#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);++i)

int main(){
	int n; cin>>n;
	int r=n%3;
	if(r==0) cout<<0<<endl;
	else if(r==1) cout<<2<<endl;
	else cout<<1<<endl;
}