#include #include #include #include using namespace std; int main() { int n; cin >> n; n = n % 6; if(n == 1){ cout << 2 << endl; }else if(n == 2){ cout << 8 << endl; }else if(n == 3){ cout << 5 << endl; }else if(n == 4){ cout << 7 << endl; }else if(n == 5){ cout << 1 << endl; }else if(n == 0){ cout << 4 << endl; } return 0; }