#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if(n % 4 == 0) {
        cout << 0 << endl; // we do not have to buy any more apples to split them equally between our nephews
    }
    else if((n + 1) % 4 == 0) {
        cout << 9 << endl; // we have to buy 1 apple with the cost of 9MKD to have apples which we can split between our nephews
    }
    else if((n + 2) % 4 == 0) {
        cout << 18 << endl; // we have to buy 2 apples with the cost of 18MKD to have apples which we can split between our nephews
    }
    else if((n + 3) % 4 == 0) {
        cout << 27 << endl; // we have to buy 3 more apples with the cost of 27MKD to have apples which can split between our nephews
    }
    
    return 0;
}
