include <iostream>

using namespace std;

int main() {
   int candy = 0;
    
    while (true){
    cin >> candy;
    if (candy == EOF) {
        break;
    }
    
    cout << candy % 39 << endl;
    
    }
}