#include <bits/stdc++.h>
using namespace std;
string s = "0", t;
int main() {
  int be_chahar;
  cin >> t;
  s += t;
  be_chahar = (s[s.size() - 1] + (10 * s[s.size() - 2])) % 4;
  cout << int((1 << be_chahar) + pow(3, be_chahar) + pow(4, be_chahar) + 1) % 5;
}
