#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int a[maxn];
int n;
void read() {
  char s[maxn];
  scanf("%s", s + 1);
  n = (int)strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = (int)(s[i] - '0');
  }
}
int ans = 1;
int k1[4] = {1, 2, 4, 3};
int k2[4] = {1, 3, 4, 2};
void sov() {
  if (a[n] & 1) {
    ans += 4;
  } else
    ans += 1;
  int x = 0;
  for (int i = 1; i <= n - 1; ++i) {
    x = x * 10 + a[i];
    if (x < 4)
      continue;
    else
      x %= 4;
  }
  x = x * 10 + a[n];
  ans += k1[x % 4] + k2[x % 4];
  printf("%d", ans % 5);
}
int main() { read(), sov(); }
