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