#include <bits/stdc++.h>
char _;
using namespace std;
template <typename T1, typename T2>
inline int max(T1 a, T2 b) {
  return (a > b ? a : b);
}
template <typename T1, typename T2>
inline int min(T1 a, T2 b) {
  return (a < b ? a : b);
}
int arr[4] = {6, 8, 4, 2};
int32_t main() {
  int n;
  cin >> n;
  if (n == 0)
    cout << 1 << endl;
  else
    cout << arr[n % 4] << endl;
  return 0;
}
