#include <bits/stdc++.h>
using namespace std;
long long int lazy[3 * 100005], tree[3 * 100005];
int main() {
  long long int i, j, k, n, tc, ca = 1, x, m, q, value, a, b;
  cin >> k;
  string s = "6842";
  if (k == 0)
    cout << 1 << endl;
  else
    cout << s[k % 4] << endl;
  return 0;
}
