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