#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100010];
  int r2[4] = {1, 2, 4, 3};
  int r3[4] = {1, 3, 4, 2};
  int r4[4] = {1, 4, 1, 4};
  while (1 == scanf("%s", s)) {
    int l = strlen(s);
    int r = 0;
    for (int i = 0; i < l; i++) {
      r = (r * 10 + s[i] - '0') % 4;
    }
    printf("%d\n", (1 + r2[r] + r3[r] + r4[r]) % 5);
  }
  return 0;
}
