#include <bits/stdc++.h>
using namespace std;
int a[] = {1, 2, 4, 3};
int b[] = {1, 3, 4, 2};
int c[] = {1, 4, 1, 4};
int d[] = {1, 1, 1, 1};
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int rem = 0;
  for (int i = 0; i < n; i++) {
    rem = (rem * 10 + s[i] - '0') % 4;
  }
  int ans = a[rem] + b[rem] + c[rem] + d[rem];
  ans %= 5;
  cout << ans;
  return 0;
}
