#include <bits/stdc++.h>
using namespace std;
char str[9999999];
int main() {
  while (~scanf("%s", str)) {
    int i, j, k = 0, l, sum = 0, Sum;
    int a[10] = {1, 2, 4, 3};
    int b[10] = {1, 3, 4, 2};
    int c[5] = {1, 4};
    j = strlen(str);
    for (i = 0; i < j; i++) k = (k * 10 + (str[i] - '0')) % 4;
    l = (str[j - 1] - '\0') % 2;
    Sum = 1 + a[k] + b[k] + c[l];
    printf("%d\n", Sum % 5);
  }
  return 0;
}
