#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long resto;
  if (n == 0)
    cout << 1 << endl;
  else {
    resto = n % 4;
    if (resto == 0)
      cout << 6 << endl;
    else if (resto == 1)
      cout << 8 << endl;
    else if (resto == 2)
      cout << 4 << endl;
    else if (resto == 3)
      cout << 2 << endl;
  }
}
