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>
template <typename T>
inline string tostring(T a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <typename T>
inline long long tolong(T a) {
  long long res;
  istringstream os(a);
  os >> res;
  return res;
}
template <typename T>
inline vector<int> parse(T str) {
  vector<int> res;
  int s;
  istringstream os(str);
  while (os >> s) res.push_back(s);
  return res;
}
template <class T>
inline T _sqrt(T x) {
  return (T)sqrt((double)x);
}
template <class T>
inline T _bigmod(T n, T m) {
  T ans = 1, mult = n % 10;
  while (m) {
    if (m & 1) ans = (ans * mult) % 10;
    m >>= 1;
    mult = (mult * mult) % 10;
  }
  ans %= 10;
  return ans;
}
template <class T>
inline T _modinv(T x) {
  return _bigmod(x, (T)10 - 2) % 10;
}
inline int LEN(string a) { return a.length(); }
inline int LEN(char a[]) { return strlen(a); }
template <class T>
inline T _gcd(T a, T b) {
  return (b == 0) ? a : _gcd(b, a % b);
}
template <class T>
inline T _lcm(T x, T y) {
  return x * y / _gcd(x, y);
}
bool compare(const pair<float, string>& i, const pair<float, string>& j) {
  return i.first > j.first;
}
int in_c() {
  int c;
  for (; (c = getchar()) <= ' ';) {
    if (!~c) throw ~0;
  }
  return c;
}
const int mx = 1e5 + 7;
int EQ(double d) {
  if (fabs(d) < 1e-9) return 0;
  return d > 1e-9 ? 1 : -1;
}
int main() {
  clock_t begin = clock();
  int n;
  cin >> n;
  if (n == 1)
    cout << "1\n";
  else
    cout << _bigmod(1378, n) << endl;
  clock_t end = clock();
  double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
  cerr << "Running Time: " << time_spent << " Seconds" << endl;
  return 0;
}
