#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
    string year, mon, day;
    vector<int> arrM = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    while (cin >> year >> mon >> day) {
        int ans = 0;
        ans += stoi(day);
        int yNum = stoi(year);
        if (((yNum % 4 == 0 && yNum % 100 != 0) || yNum % 400 == 0) && stoi(mon) > 2)
            ans += 1;
        for (int i = 0; i < stoi(mon) - 1; ++i) {
            ans += arrM[i];
        }
        cout << ans << endl;
    }
    return 0;
}