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