#define _GLIBCXX_DEBUG #include using namespace std; int main() { int N; cin >> N; vector ans = {2, 8, 5, 7, 1, 4}; cout << ans[(N-1)%6] << endl; }