#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
int main() {
  long long n;
  cin >> n;
  if (n == 0)
    cout << 1 << endl;
  else if (n % 4 == 0)
    cout << 6 << endl;
  else if (n % 4 == 1)
    cout << 8 << endl;
  else if (n % 4 == 2)
    cout << 4 << endl;
  else if (n % 4 == 3)
    cout << 2 << endl;
  return 0;
}
