#include <iostream>
using namespace std;

int main() {
    int x;
    cin >> x;
    
    if(x % 4 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << (4 - (x % 4)) * 9 << endl;
    }
    return 0;
}
