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