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