#include <bits/stdc++.h>
using namespace std;
const int MaxN = int(1e5) + 256;
const int INF = int(1e9);
long long n = 1, m = 1, sum, sum2, last, two[5] = {6, 2, 4, 8},
          tr[5] = {1, 3, 9, 7}, fo[3] = {6, 4};
string s;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  if (s.size() == 1) {
    last = s[s.size() - 1] - '0';
    last %= 4;
  } else {
    last = s[s.size() - 1] - '0' + (s[s.size() - 2] - '0') * 10;
    last %= 4;
  }
  cout << (two[last] + tr[last] + 1 + fo[last % 2]) % 5;
  return 0;
}
