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