#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  if (n == 0) {
    cout << "1" << endl;
  } else {
    long long ans = n % 4;
    if (ans == 0) {
      cout << "6" << endl;
    }
    if (ans == 1) {
      cout << "8" << endl;
    }
    if (ans == 2) {
      cout << "4" << endl;
    }
    if (ans == 3) {
      cout << "2" << endl;
    }
  }
  return 0;
}
