#include <bits/stdc++.h>
using namespace std;
int A[4] = {1, 2, 4, 3};
int B[4] = {1, 3, 4, 2};
int C[4] = {1, 4, 1, 4};
int main() {
  string s;
  while (cin >> s) {
    int x = 0;
    for (int i = 0; i < s.length(); i++) {
      int y = int(s[i]) - int('0');
      x = (x * 10 + y) % 4;
    }
    int res = (A[x] + B[x] + C[x] + 1) % 5;
    cout << res << endl;
  }
  return 0;
}
