#include <bits/stdc++.h>
unsigned raise(unsigned base, unsigned power) {
  unsigned value = 1;
  while (power != 0) {
    if (power & 1) value = value * base % 5;
    base = base * base % 5;
    power /= 2;
  }
  return value;
}
void answer(unsigned v) { std::cout << v << '\n'; }
void solve(const std::string& n) {
  const size_t k = n.length();
  const unsigned e = ((k > 1 ? n[k - 2] - '0' : 0) * 10 + (n[k - 1] - '0')) % 4;
  const unsigned s = 1 + raise(2, e) + raise(3, e) + raise(4, e);
  answer(s % 5);
}
int main() {
  std::string n;
  std::cin >> n;
  solve(n);
  return 0;
}
