#include "bits/stdc++.h" using namespace std; int main() { int N, X[6] = { 2, 8, 5, 7, 1, 4 }; cin >> N; cout << X[(N - 1) % 6] << endl; }