#include <bits/stdc++.h>
using namespace std;
char s[100005];
void input() {
  int i, n, x, y, z, t, len, mod4;
  scanf("%s", &s);
  len = strlen(s);
  x = 1;
  mod4 = 0;
  for ((i) = 0; (i) < (len); (i)++) mod4 = (mod4 * 10 + s[i] - '0') % 4;
  if (mod4 == 0)
    y = 1, z = 1;
  else if (mod4 == 1)
    y = 2, z = 3;
  else if (mod4 == 2)
    y = 4, z = 4;
  else
    y = 3, z = 2;
  t = ((s[len - 1] - '0') % 2 == 1 ? 4 : 1);
  printf("%d\n", (x + y + z + t) % 5);
}
int main() {
  input();
  return 0;
}
