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