#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  if (n == 0) {
    cout << 1;
    return 0;
  }
  int a = 8;
  long long int result = 1L;
  while (n > 0) {
    if (n & 1) result = (result * a) % 10;
    a = (a * a) % 10;
    n >>= 1;
  }
  cout << result;
}
