#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, Odd;
  cin >> N;
  if (N == 0) {
    cout << 1;
    return 0;
  }
  Odd = N % 4;
  switch (Odd) {
    case 0:
      cout << 6;
      break;
    case 1:
      cout << 8;
      break;
    case 2:
      cout << 4;
      break;
    case 3:
      cout << 2;
      break;
  }
  return 0;
}
