#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e6 + 5;
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 1;
  for (int i = s.size(); i > 0; i--) {
    a[i] = s[n - i] - '0';
  }
  int num = 100 * a[3] + 10 * a[2] + a[1];
  int num1 = (num + 4) % 100;
  int num2 = (num + 3) % 100;
  int num3 = (num + 2) % 100;
  int num4 = (num + 1) % 100;
  if (num1 % 4 == 0)
    ans += 2;
  else if (num2 % 4 == 0)
    ans += 5;
  else if (num3 % 4 == 0)
    ans += 8;
  else if (num4 % 4 == 0)
    ans += 5;
  int num5 = (num + 2) % 10;
  int num6 = (num + 1) % 10;
  if (num5 % 2 == 0)
    ans += 1;
  else if (num6 % 2 == 0)
    ans += 4;
  cout << ans % 5;
  return 0;
}
