#include <bits/stdc++.h>
int main() {
  int n, l = 0, i;
  char arr[1000001];
  scanf("%s", &arr);
  for (i = 0; i < 1000001; i++)
    if (arr[i] == 0) break;
  if (i == 1)
    n = arr[0] - 48;
  else
    n = arr[i - 1] - 48 + 10 * (arr[i - 2] - 48);
  if (n % 4 == 1)
    l += 1 + 2 + 3 + 4;
  else if (n % 4 == 2)
    l += 1 + 4 + 4 + 1;
  else if (n % 4 == 3)
    l += 1 + 3 + 2 + 4;
  else
    l += 1 + 1 + 1 + 1;
  printf("%d", l % 5);
  return 0;
}
