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;
const int iinf = 0x7fffffff;
const long long linf = ~(1LL << 63);
template <typename T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long qpow(long long a, long long n, long long mod) {
  a %= mod;
  long long ans = 1LL;
  while (n) {
    if (n & 1) ans = (ans * a % mod);
    a = (a * a % mod);
    n >>= 1;
  }
  return ans;
}
inline long long rev(long long a, long long p) { return qpow(a, p - 2, p); }
template <typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
  DST[s] = SRC[s];
  for (int i = 1; i < N; i++) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() {
  int x;
  cin >> x;
  return x;
}
inline void tic() {}
inline void toc() {}
int main() {
find_me_at:
http:
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  cout << qpow(1378, n, 10) << endl;
  return 0;
}
