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

int func(int y, int m, int d) {
    int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)  months[2] = 29;
    int res = 0;
    for (int i = 0; i < m; i++) {
        res += months[i];
    }
    res += d;
    return res;
}

int main() {
    int y, m, d;
    while (cin >> y >> m >> d) {
        int r = func(y, m, d);
        cout << r << endl;
    }
}
// 64 位输出请用 printf("%lld")