#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  if (str.length() == 1 && str[0] == '0') {
    cout << 4;
    return 0;
  }
  int n2 = (str[str.length() - 1] - '0') % 2;
  int n4 = ((str[str.length() - 1] - '0') +
            ((str.length() > 1) ? 10 * (str[str.length() - 2] - '0') : 0)) %
           4;
  int ans =
      (1 + ((int)pow(2.0, n4)) + ((int)pow(3.0, n4)) + ((int)n2 == 0 ? 6 : 4)) %
      5;
  cout << ans;
  return 0;
}
