#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n < 2) {
    return 0;
  }
  if (n % 2 == 0) {
    return n == 2;
  }
  for (int i = 3; i * i <= n; i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long ncr(int n, int r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return n * ncr(n - 1, r - 1) / r;
}
int knapSack(vector<int> values, vector<int> weights, int maximumWeight) {
  int N = values.size();
  int W = maximumWeight;
  vector<vector<int>> V(N + 1, vector<int>(W + 1, 0));
  for (int i = 0; i <= N; i++) {
    V[i][0] = 0;
  }
  for (int i = 0; i <= W; i++) {
    V[0][i] = 0;
  }
  for (int item = 1; item <= N; item++) {
    for (int weight = 1; weight <= W; weight++) {
      if (weights[item - 1] <= weight) {
        V[item][weight] =
            max(values[item - 1] + V[item - 1][weight - weights[item - 1]],
                V[item - 1][weight]);
      } else {
        V[item][weight] = V[item - 1][weight];
      }
    }
  }
  return V[N][W];
}
const int P = 5;
int powmod(int x, int n, int P) {
  x %= P;
  int res = 1 % P;
  while (n) {
    if ((n & 1)) {
      res = (res * x) % P;
      n--;
    } else {
      x = (x * x) % P;
      n >>= 1;
    }
  }
  return res;
}
int myPow(int x, string s, int P) {
  x %= P;
  int res = 1 % P;
  int now = x;
  for (int i = (int)s.size() - 1; i >= 0; i--) {
    res = (res * powmod(now, s[i] - '0', P)) % P;
    now = powmod(now, 10, P);
  }
  return res;
}
int main() {
  string s;
  cin >> s;
  cout << (myPow(1, s, 5) + myPow(2, s, 5) + myPow(3, s, 5) + myPow(4, s, 5)) %
              5
       << "\n";
  return 0;
}
