#include <bits/stdc++.h>
using namespace std;
int getPower(vector<int> V, int b) {
  int c = 0;
  for (int i = 0; i < V.size(); i++) {
    c = c * 10 + V[i];
    c %= b;
  }
  return c;
}
int Power(int N, int p) {
  int d = 1;
  for (int i = 0; i < p; i++) d *= N;
  return d;
}
int main() {
  char ch;
  ch = getchar();
  vector<int> Number;
  while (ch != '\n' && ch != EOF) {
    Number.push_back(ch - '0');
    ch = getchar();
  }
  int n1 = getPower(Number, 4);
  int n2 = getPower(Number, 2);
  int S = (1 + (Power(2, n1) % 5)) % 5;
  S = (S + (Power(3, n1)) % 5) % 5;
  S = (S + (Power(4, n2)) % 5) % 5;
  printf("%d", S);
  return 0;
}
