#include <bits/stdc++.h>
using namespace std;
int X2(string n) {
  int len = n.length(), ans = 0;
  for (int i = 0; i < len; i++) {
    ans = (int)(((long long)ans * 10 + n[i] - '0') % 4);
  }
  if (ans == 1) return 2;
  if (ans == 2) return 4;
  if (ans == 3) return 8;
  if (ans == 0) return 6;
}
int X3(string n) {
  int len = n.length(), ans = 0;
  for (int i = 0; i < len; i++) {
    ans = (int)(((long long)ans * 10 + n[i] - '0') % 4);
  }
  if (ans == 1) return 3;
  if (ans == 2) return 9;
  if (ans == 3) return 7;
  if (ans == 0) return 1;
}
int X4(string n) {
  int len = n.length(), ans = 0;
  for (int i = 0; i < len; i++) {
    ans = (int)(((long long)ans * 10 + n[i] - '0') % 2);
  }
  if (ans == 1) return 4;
  if (ans == 0) return 6;
}
int main() {
  string s;
  while (cin >> s) {
    int ans = 1 + X2(s) + X3(s) + X4(s);
    cout << ans % 5 << endl;
  }
  return 0;
}
