#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int mod = 10;
int bin(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  cout << bin(1378, n) << '\n';
  return 0;
}
