#include <bits/stdc++.h>
using namespace std;
int power(int base, int exponent, int mod) {
  int x = 1;
  for (int i = 0; i < exponent; i++) {
    x = (x * base) % mod;
  }
  return x;
}
int main() {
  string input;
  cin >> input;
  int n;
  if (input.size() <= 2)
    n = atoi(input.c_str());
  else {
    string last = input.substr(input.size() - 2);
    n = atoi(last.c_str());
  }
  n = n % 4;
  int answer = 0;
  for (int i = 1; i <= 4; i++) {
    answer += power(i, n, 5);
  }
  cout << answer % 5 << endl;
}
