#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;
}
