#include <bits/stdc++.h>
#define ll long long
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define opps cout<<-1<<endl;
const ll con = 1e10 + 5;
using namespace std;
int getex(int x) {
    return (x % 4);
}
ll powx(int base, int x) {
    return pow(base, x);
}
void solve() {
    string s;
    cin >> s;
    int x = (s[s.length() - 1] - '0') ;
    (s.length() > 1 ) ? x += 10 * (s[s.length() - 2] - '0') : x += 0;
    int ex = getex(x);
    ll sumx = powx(1 , ex) + powx(2 , ex)+powx(3 , ex) + powx(4 , ex);
    cout<<sumx % 5 ;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}