#include <bits/stdc++.h>
using namespace std;
long long Quick_pow(long long x, long long n, long long Mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % Mod;
    n >>= 1;
    x = x * x % Mod;
  }
  return res;
}
int main(void) {
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 1 << endl;
  } else {
    cout << Quick_pow(8, n, 10) << endl;
  }
  return 0;
}
