#include #include #include #include #include #include #define _USE_MATH_DEFINENS #include using namespace std; #define p(x) cout << x << endl; #define el cout << endl; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int ddd[] = {4, 2, 8, 5, 7, 1}; cout << ddd[n % 6] << endl; }