#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 1;
const int LINF = (long long)1e18 + 1;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int powMod(int n) {
  int res = 1, x = 8;
  while (n) {
    if (n % 2 == 1) {
      res *= x;
      res %= 10;
    }
    x *= x;
    x %= 10;
    n /= 2;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  cout << powMod(n) << endl;
  return 0;
}
