#include <bits/stdc++.h>
using namespace std;
void solve() {
  string number;
  cin >> number;
  int n = number.length();
  int answer;
  vector<vector<int> > remainders = {
      {}, {1}, {1, 2, 4, 3}, {1, 3, 4, 2}, {1, 4}};
  int last_digit = number[n - 1] - '0';
  if (n == 1) {
    answer = (remainders[1][last_digit % 1] + remainders[2][last_digit % 4] +
              remainders[3][last_digit % 4] + remainders[4][last_digit % 2]) %
             5;
  } else {
    int last_two_digits = (number[n - 1] - '0') + 10 * (number[n - 2] - '0');
    answer = (remainders[1][last_two_digits % 1] +
              remainders[2][last_two_digits % 4] +
              remainders[3][last_two_digits % 4] +
              remainders[4][last_two_digits % 2]) %
             5;
  }
  cout << answer << endl;
}
int main() {
  {
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  }
  solve();
  return 0;
}
