#include <bits/stdc++.h>
using namespace std;
set<char> st;
set<char>::iterator it;
map<char, int> mp;
map<char, int>::iterator itr;
pair<int, int> pr[1000000];
int ans[1000] = {0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  long long a;
  cin >> a;
  if (a == 0)
    cout << '1' << endl;
  else if (a % 4 == 0)
    cout << 6 << endl;
  else if (a % 4 == 1)
    cout << 8 << endl;
  else if (a % 4 == 2)
    cout << 4 << endl;
  else if (a % 4 == 3)
    cout << 2 << endl;
}
