12
 1378
 51202278
 989898989
 4
 7
 9
 6
 8
 12193721
 999999995
 999999999
 11
 999999996
 999999998
 3
 14
 15
 10
 999999994
 1000
 13781378
 5
 999999997
 1000000000
 13
 16
 0

6
 4
 4
 8
 6
 2
 8
 4
 6
 8
 2
 2
 2
 6
 4
 2
 4
 2
 4
 4
 6
 4
 8
 8
 6
 8
 6
 1

#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;
}
