#include <bits/stdc++.h>
using namespace std;
int m1[4] = {1, 1, 1, 1};
int m2[4] = {1, 2, 4, 3};
int m3[4] = {1, 3, 4, 2};
int m4[4] = {1, 4, 1, 4};
int main() {
  string s;
  cin >> s;
  int b = s[s.size() - 1] - '0';
  int a;
  if (s.size() > 1)
    a = s[s.size() - 2] - '0';
  else
    a = 0;
  int n = (10 * a + b) % 4;
  cout << (m1[n] + m2[n] + m3[n] + m4[n]) % 5;
  return 0;
}
