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