#include <bits/stdc++.h>
using namespace std;
char str[int(1e5 + 1000)];
int mod() {
  int ans = 0, i = -1;
  while (str[++i] != '\0') {
    ans = (ans * 10 + str[i] - '0') % 4;
  }
  return ans;
}
int main() {
  int n, ans = 1;
  scanf("%s", str);
  int m = mod();
  int tmp = pow(2, m);
  ans += tmp % 5;
  tmp = pow(3, m);
  ans += tmp % 5;
  tmp = pow(4, m);
  ans += tmp % 5;
  ans %= 5;
  printf("%d\n", ans);
}
