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;
template <class T>
inline void IO(T &x) {
  char c = getchar();
  T sgn = 1;
  while (c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  x = 0;
  while (c >= '0' && c <= '9') {
    x = (T)(x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  x *= sgn;
}
template <class T>
T POW(T b, T push) {
  T res = 1;
  while (push > 0) {
    if (push & 1) res *= b;
    push >>= (1ll), b *= b;
  }
  return res;
}
template <class T>
T bMOD(T a, T push, T m) {
  if (push == 0) return (T)1;
  if (!(push & 1)) {
    T temp = bMOD(a, push / 2, m);
    return ((temp % m) * (temp % m)) % m;
  }
  return ((a % m) * (bMOD(a, push - 1, m) % m)) % m;
}
template <class T>
T inMOD(T a, T m) {
  return bMOD(a, m - 2, m);
}
template <class T>
bool isPrime(T n) {
  for (T i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
template <class T>
string toString(T n) {
  stringstream second;
  string num;
  second << n;
  second >> num;
  return num;
}
template <class T>
T sq(T n) {
  return (n * n);
}
template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
bool iseq(double a, double b) { return fabs(a - b) < 1e-9; }
template <class T>
T toDeg(T x) {
  return (180.0 * x) / ((T)acos(-1.0));
}
template <class T>
T toReg(T x) {
  return (x * (T)acos(-1.0)) / (180.0);
}
template <class T>
double _distance(T x1, T y1, T x2, T y2) {
  return 1.0 * sqrt(sq(x1 - x2) + sq(y1 - y2));
}
int kx[] = {-2, -2, +2, +2, +1, -1, +1, -1};
int ky[] = {+1, -1, +1, -1, -2, -2, +2, +2};
int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1};
int dy[] = {+1, -1, +0, +0, -1, +1, +1, -1};
int main() {
  int n;
  cin >> n;
  int ans = bMOD(8, n, 10);
  cout << ans << endl;
  return 0;
}
