#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int n, x = 0, ans;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) {
    x = x * 10 + (s[i] - '0');
    x = x % 4;
  }
  ans = (1 + (int)pow(2, x) + (int)pow(3, x) + (int)pow(4, x)) % 5;
  cout << ans << "\n";
}
