#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int M = 1e9 + 7;
long long mod(long long x) { return ((x % M + M) % M); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long modPow(long long a, long long b) {
  if (b == 0) return 1LL;
  if (b == 1) return a % M;
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = mul(res, a);
    a = mul(a, a);
    b = b / 2;
  }
  return res;
}
long long inv(long long x) { return modPow(x, M - 2); }
long long divide(long long a, long long b) { return mul(a, inv(b)); }
long long sumofdigits(long long n) {
  if (n < 10) return n;
  long long digit = 0;
  long long sum = 0;
  while (n > 0) {
    digit = n % 10;
    sum = sum + digit;
    n = n / 10;
  }
  return sum;
}
long long modex(long long x, long long y, long long n) {
  if (y == 0) return 1;
  if (y % 2 == 0) {
    long long half_number = modex(x, y / 2, n);
    return (half_number * half_number) % n;
  } else {
    long long half_number = modex(x, y / 2, n);
    half_number = (half_number * half_number) % n;
    half_number = (half_number * x) % n;
    return half_number;
  }
}
vector<long long> createsieve(long long n) {
  vector<long long> primes;
  vector<long long> sieve(n + 1);
  for (long long i = 2; i * i <= n; i++) {
    if (sieve[i] == 0) {
      for (long long j = i * i; j <= n; j += i) {
        sieve[j] = 1;
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (sieve[i] == 0) {
      primes.push_back(i);
    }
  }
  return primes;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool isPalindrome(string s, int l, int r) {
  if (l >= r) return true;
  if (s[l] != s[r]) {
    return false;
  }
  return isPalindrome(s, l + 1, r - 1);
}
long long getonebits(long long n) {
  long long count = 0;
  while (n != 0) {
    n = n & (n - 1);
    count++;
  }
  return count;
}
long long fact(long long n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
long long inv(long long a, long long m) {
  long long m0 = m, t, q;
  long long x0 = 0, x1 = 1;
  if (m == 1) return 0;
  while (a > 1) {
    q = a / m;
    t = m;
    m = a % m, a = t;
    t = x0;
    x0 = x1 - q * x0;
    x1 = t;
  }
  if (x1 < 0) x1 += m0;
  return x1;
}
long long crt(long long num[], long long rem[], long long k) {
  long long prod = 1;
  for (long long i = 0; i < k; i++) prod *= num[i];
  long long result = 0;
  for (long long i = 0; i < k; i++) {
    long long pp = prod / num[i];
    result += rem[i] * inv(pp, num[i]) * pp;
  }
  return result % prod;
}
long long nCr(long long n, long long r) {
  return fact(n) / (fact(n - r) * fact(r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 1 << "\n";
    return 0;
  }
  long long k = n % 4;
  if (k == 0) {
    cout << 6 << "\n";
  } else if (k == 1) {
    cout << 8 << "\n";
  } else if (k == 2) {
    cout << 4 << "\n";
  } else {
    cout << 2 << "\n";
  }
  return 0;
}
