#include <bits/stdc++.h>
using namespace std;
int main() {
  char ip[1000000];
  scanf("%s", ip);
  int len = strlen(ip);
  int temp = 1;
  int result = 1;
  int last = ip[len - 1] - '0';
  int secondlast = ip[len - 2] - '0';
  if (last % 2 == 0)
    result += 6;
  else
    result += 4;
  if (len >= 2)
    temp = secondlast * 10 + last;
  else
    temp = last;
  if (temp % 4 == 0) {
    result += 7;
  } else if (temp % 4 == 1) {
    result += 15;
  } else if (temp % 4 == 2) {
    result += 13;
  } else {
    result += 5;
  }
  printf("%d ", result % 5);
  return 0;
}
