#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[100010];
  scanf("%s", str);
  int s = strlen(str);
  int n;
  for (int i = 0; i < s; i++) {
    if (i == s - 3) {
      int a = str[i] - '0';
      n = a * 100;
    }
    if (i == s - 2) {
      int b = (str[i]) - '0';
      n = n + (10 * b);
    }
    if (i == s - 1) {
      int c = (str[i]) - '0';
      n = n + c;
    }
  }
  int mod = n % 4;
  int ans = 1;
  if (mod == 1) {
    ans = ans + 2 + 3 + 4;
  } else if (mod == 2) {
    ans = ans + 4 + 4 + 1;
  } else if (mod == 3) {
    ans = ans + 5 + 4;
  } else if (mod == 0) {
    ans = ans + 2 + 1;
  } else {
  }
  printf("%d\n", (ans % 5));
  return 0;
}
