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