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