#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = (int)s.length();
  vector<int> mod2 = {1, 2, 4, 3};
  vector<int> mod3 = {1, 3, 4, 2};
  vector<int> mod4 = {1, 4, 1, 4};
  int ind = 0;
  char c1, c2;
  if (n == 1) {
    c1 = s[0];
    int x = c1 - '0';
    ind = x % 4;
  } else {
    c1 = s[n - 2];
    c2 = s[n - 1];
    int x = (c1 - '0') * 10 + (c2 - '0');
    ind = x % 4;
  }
  cout << (1 + mod2[ind] + mod3[ind] + mod4[ind]) % 5 << endl;
}
