#include <bits/stdc++.h>
const int len = 1e9 + 7;
using namespace std;
void solve() {
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 1;
    return;
  }
  if (n % 4 == 0)
    cout << 6;
  else if (n % 4 == 1)
    cout << 8;
  else if (n % 4 == 2)
    cout << 4;
  else
    cout << 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
