#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n;
  scanf("%d", &n);
  if (n == 0) {
    printf("1");
    return 0;
  }
  int v[4] = {6, 8, 4, 2};
  printf("%d", v[n % 4]);
}
