#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n, long long m) { return m ? gcd(m, n % m) : n; }
long long lcm(long long n, long long m) { return n / gcd(n, m) * m; }
struct debugger {
  static void call(string::iterator it, string::iterator ed) {}
  template <typename T, typename... aT>
  static void call(string::iterator it, string::iterator ed, T a, aT... rest) {
    string b;
    for (; *it != ','; ++it)
      if (*it != ' ') b += *it;
    cout << b << "=" << a << " ";
    call(++it, ed, rest...);
  }
};
long long power(long long n) {
  long long a = 8, res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % 10;
      n--;
    } else {
      a = (a * a) % 10;
      n /= 2;
    }
  }
  return res;
}
void solve() {
  long long n;
  scanf("%lld", &n);
  cout << power(n) << '\n';
}
int main() {
  solve();
  cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
  ;
  return 0;
}
