#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "0") {
    cout << '4';
    return 0;
  }
  if (s.length() == 1) s = "0" + s;
  int l = (s[s.length() - 2] - 48) * 10 + (s[s.length() - 1] - 48);
  l = l % 4;
  int t;
  if (l == 1) t = 2;
  if (l == 2) t = 4;
  if (l == 3) t = 3;
  if (l == 0) t = 1;
  int u;
  if (l == 1) u = 3;
  if (l == 2) u = 4;
  if (l == 3) u = 2;
  if (l == 0) u = 1;
  int o;
  if ((int)s[s.length() - 1] % 2 == 0)
    o = 1;
  else
    o = 4;
  int sum = (1 + t + u + o) % 5;
  cout << sum;
  return 0;
}
