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

vector<vector<int>> month {{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}};

bool isLeap(int year){
    return (year%4==0&&year%100!=0)||year%400==0;
}

int main() {
    int y,m,d;
    while (cin >> y>>m>>d) { // 注意 while 处理多个 case
        int r=0,count=0;
        if(isLeap(y))
            r++;
        for(int i=0;i<m-1;i++){
            count+=month[r][i];
        }
        count+=d;
        cout<<count<<endl;
    }
}
// 64 位输出请用 printf("%lld")