#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
const int M = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout.setf(ios::fixed);
  LL n, i, j, m;
  string s[4];
  s[0] = "1111";
  s[1] = "1243";
  s[2] = "1342";
  s[3] = "1414";
  string t;
  cin >> t;
  LL k;
  n = t.size();
  k = (n >= 2 ? (t[n - 2] - '0') : 0) * 10 + (t[n - 1] - '0');
  LL ans = 0;
  k %= 4;
  for (i = 0; i < 4; i++) ans += (s[i][k] - '0');
  ans %= 5;
  cout << ans << '\n';
}
