#include <bits/stdc++.h>
using namespace std;
char ch[1000000];
int main() {
  int n = 0;
  scanf("%s", ch);
  int l = strlen(ch);
  if (l == 1)
    n = ch[0] - '0';
  else
    n = 10 * (ch[l - 2] - '0') + ch[l - 1] - '0';
  n %= 4;
  int ans = 0;
  for (int i = 1; i <= 4; i++) {
    int t = 1;
    for (int j = 0; j < n; j++) t *= i;
    ans += t;
  }
  printf("%d\n", ans % 5);
  return 0;
}
