#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int mod4 = (s[n - 2] - '0') * 10 + (s[n - 1] - '0') & 3;
  int p2[] = {1, 2, 4, 3};
  int p3[] = {1, 3, 4, 2};
  int p4[] = {1, 4, 1, 4};
  cout << (1 + p2[mod4] + p3[mod4] + p4[mod4]) % 5 << endl;
}
