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;
bool primes[1000000 + 1];
void sieve(long long int n) {
  primes[0] = false;
  primes[1] = false;
  for (long long int i{2}; i <= n; i++) {
    primes[i] = true;
  }
  for (long long int i{2}; i <= sqrt(n); i++) {
    if (primes[i] == true) {
      for (long long int j{2}; j * i <= n; j++) {
        primes[i * j] = false;
      }
    }
  }
}
bool comp(pair<int, int> &a, pair<int, int> &b) { return (a.first < b.first); }
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
long long int fastpow(long long base, long long n) {
  if (n == 0) return 1;
  if (n == 1) return base % 10;
  long long halfn = fastpow(base % 10, n / 2) % 10;
  if (n % 2 == 0)
    return ((halfn) * (halfn)) % 10;
  else
    return (((halfn * halfn)) * base) % 10;
}
void bfs(int s, vector<int> v[], bool vis[]) {
  queue<int> q;
  q.push(s);
  vis[s] = true;
  while (!q.empty()) {
    int a = q.front();
    q.pop();
    for (auto x : v[a]) {
      if (!vis[x]) {
        q.push(x);
        vis[x] = true;
      }
    }
  }
}
void dfs(int s, vector<int> v[], bool vis[]) {
  vis[s] = true;
  for (auto x : v[s]) {
    if (!vis[x]) {
      dfs(x, v, vis);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  cout << fastpow(8, n) << "\n";
  return 0;
}
