#include <bits/stdc++.h>
int n, res;
void qread(int &x) {
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) x = (x * 10 + c - 48) % 100;
  return;
}
void Add2() {
  if ((n & 3) == 1)
    res += 2;
  else if ((n & 3) == 2)
    res += 4;
  else if ((n & 3) == 3)
    res += 3;
  else
    res += 1;
  return;
}
void Add3() {
  if ((n & 3) == 1)
    res += 3;
  else if ((n & 3) == 2)
    res += 4;
  else if ((n & 3) == 3)
    res += 2;
  else
    res += 1;
  return;
}
void Add4() {
  if ((n & 1))
    res += 4;
  else
    res += 1;
  return;
}
int main() {
  qread(n);
  Add2();
  Add3();
  Add4();
  printf("%d\n", (res + 1) % 5);
  return 0;
}
