// in the name of GOD #include <iostream> using namespace std; int n; int main() { cin >> n; if (n <= 186) // 186 is the last day of Shahrivar cout << n % 31 << endl; else { n -= 186; cout << n % 30 << endl; } return 0; }