#include <iostream>
using namespace std;


int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int sum[13];

bool judge(int y){
    if(y % 400 == 0 || y % 100 != 0 && y % 4 == 0)
        return true;
    return false;
}

int main() {
    int y, m, d;
    for(int i = 1; i <= 12; i ++) sum[i] = sum[i - 1] + a[i];

    while (cin >> y >> m >> d) {
        if(judge(y) && m - 1 >= 2)
            cout << sum[m - 1] + 1 + d << endl;
        else
            cout << sum[m - 1] + d << endl;
    }

    return 0;
}
// 64 位输出请用 printf("%lld")