#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
string s;
int ost;
inline long long binpow(int n, int a) {
  if (n == 0) return 1;
  if (n % 2 == 1) return binpow(n - 1, a) * a;
  long long b = binpow(n >> 1, a);
  return b * b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  if (s.size() == 1)
    ost = (s[s.size() - 1] - '0');
  else
    ost = (s[s.size() - 2] - '0') * 10 + (s[s.size() - 1] - '0');
  ost %= 4;
  long long ans = 0;
  for (int i = 1; i <= 4; i++) ans += binpow(ost, i);
  cout << ans % 5;
}
