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