#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     if (n == 0)       cout << 1;     else {       n %= 4;       if (n == 0) n = 4;       n = pow(8, n);       cout << n % 10;     }   }   