#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC target("avx", "sse4", "sse4.2", "sse3")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
using namespace std;
int main() {
  int arr[] = {6, 8, 4, 2};
  int n;
  cin >> n;
  if (n == 0)
    cout << 1 << endl;
  else
    cout << arr[n % 4] << endl;
  return 0;
}
