#include <bits/stdc++.h>
using namespace std;
//判断闰年平年, 每月天数,4 6 9 11,四个月为小月, 7个月为大月1 3 5 7 8 10 12, 一个特殊月,闰年29天,平年28天
int moth[13]={0,31, 28,31, 30, 31,30,31,31,30,31,30,31};
int main() {
    int Y, M ,D;
    while(cin >>Y >> M >> D){
        //判断,能被400整除 或者能被4整除,但不能被100整除的叫2月28天
        //初始化
        int  days = 0;
        moth[2] = 28;
        if(Y%400 == 0 || (Y%4==0 && Y%100 != 0)){//闰年判断条件
            moth[2] = 29;
        }
        //计算天数
        for(int i =1; i<M; i++){
            days += moth[i];
        }
        days += D;
        cout << days << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")