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 int mod = 10;
long long int fact[1000100 + 10], inv[1000100 + 10];
long long int fpow(long long int a, long long int b) {
  long long int ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ret;
}
long long int strint(char str[]) {
  long long int ret = 0;
  for (int i = 0; i < strlen(str); i++) ret = (ret * 10 + str[i] - '0') % mod;
  return ret;
}
long long int invmod(long long int a) { return fpow(a, mod - 2); }
long long int precalc() {
  fact[0] = 1;
  fact[1] = 1;
  inv[0] = 1;
  inv[1] = 1;
  for (long long int i = 2; i < 1000100 + 10; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
}
vector<long long int> factorize(int n) {
  long long int ret = 0, f = 0;
  vector<long long int> v;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      f++;
      v.push_back(i);
      n /= i;
    }
  }
  if (n > 2) v.push_back(n);
  return v;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
bool chkPrimeExtra(int n) {
  if (n == 0 || n == 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0) return false;
  for (int i = 3; i * i <= n; i += 4)
    if (n % i == 0 or (n % (i + 2)) == 0) return false;
  return true;
}
int chkPrime(int n) {
  int count = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i == n)
        count++;
      else
        count += 2;
    }
  }
  if (count == 2)
    cout << "Prime" << endl;
  else
    cout << "Non-Prime" << endl;
  return count;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long int n2, n3, k5 = 0, k6;
  cin >> n2;
  cout << fpow(1378, n2);
}
