#include
using namespace std;
int main() {
int n;
cin >> n;
int prv_slucaj = n;
int vtor_slucaj = n + 1;
int tret_slucaj = n + 2;
int cetvrti_slucaj = n + 3;
if(prv_slucaj % 4 == 0) {
cout << 9 * 0 << endl;
}
else if(vtor_slucaj % 4 == 0) {
cout << 9 * 1<< endl;
}
else if(tret_slucaj % 4 == 0) {
cout << 9 * 2 << endl;
}
else {
cout << 9 * 3 << endl;
}
return 0;
}