#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.first == b.first) ? (a.second < b.second) : (a.first < b.first);
}
int func(string str, int p) {
  int res = 1, n, x = 1, len = str.size();
  for (int i = 0; i < 2; i++) {
    n = str[len - 1 - i] - '0';
    if (i != 0) {
      x = 10;
    }
    n = (n * x) % 4;
    res = (res * ((int)pow(p, n) % 5)) % 5;
    if (len == 1) break;
  }
  return res;
}
int main() {
  string str;
  cin >> str;
  int len = str.size();
  int res = 1, n, x = 1;
  res = (res + func(str, 2)) % 5;
  res = (res + func(str, 3)) % 5;
  res = (res + func(str, 4)) % 5;
  cout << res;
}
