#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int res = 1;
    char c1 = s[s.length() - 1];
    int cc = int(c1) - int('0');
    if (s.length() == 1) {
      if (c1 == '4' || c1 == '8' || c1 == '0')
        res += 2;
      else {
        if (cc % 4 == 1)
          res += 5;
        else if (cc % 4 == 2)
          res += 8;
        else if (cc % 4 == 3)
          res += 5;
      }
    } else {
      char c2 = s[s.length() - 2];
      if ((c1 == '0' || c1 == '4' || c1 == '8') && (c2 % 2 == 0))
        res += 2;
      else if ((c1 == '2' || c1 == '6') && (c2 % 2 != 0))
        res += 2;
      else {
        int cc1 = cc + 10 * (int(c2) - int('0'));
        if (cc1 % 4 == 1)
          res += 5;
        else if (cc1 % 4 == 2)
          res += 8;
        else if (cc1 % 4 == 3)
          res += 5;
      }
    }
    if (cc % 2 == 0)
      res++;
    else
      res += 4;
    res = res % 5;
    cout << res << endl;
  }
  return 0;
}
