#include <bits/stdc++.h>
int a = 0, b = 0;
int main() {
  char e = getchar();
  while (e >= '0' && e <= '9') {
    a = b;
    b = e - '0';
    e = getchar();
  }
  b += a * 10;
  b %= 4;
  int ans = 1;
  if (b == 1) ans += 9;
  if (b == 2) ans += 9;
  if (b == 3) ans += 9;
  if (b == 0) ans += 3;
  ans %= 5;
  printf("%d\n", ans);
  return 0;
}
