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