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