#include <bits/stdc++.h>
using namespace std;
int power(int n, int p) {
  int r = 1;
  for (int i = 0; i < p; i++) r *= n;
  return r;
}
void solve() {
  string line;
  getline(cin, line);
  int p = (line[line.size() - 1] - '0');
  if (line.size() > 1) {
    p += 10 * (line[line.size() - 2] - '0');
  }
  int answer = (1 + power(2, p % 4) + power(3, p % 4) + power(4, p % 2)) % 5;
  printf("%d\n", answer);
}
int main() {
  solve();
  return 0;
}
