#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0 || a == 0) return a + b;
  return gcd(b, a % b);
}
const int inf = int(1e9);
const int mod = inf + 7;
void solve() {
  int n;
  cin >> n;
  if (n == 0) {
    cout << 1;
    return;
  }
  n %= 4;
  if (n == 0)
    cout << 6;
  else if (n == 1)
    cout << 8;
  else if (n == 2)
    cout << 4;
  else
    cout << 2;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
