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