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