//利用数组存储每月日数,即空间换时间
#include "stdio.h"
int main(){
    int year,mouth,day;
    int map[13] = {0,31,28,31,30,31,30,
                   31,31,30,31,30,31};
    while (scanf("%d%d%d",&year,&mouth,&day)!=EOF) {
        bool special;int sum = 0;
        if(year%400==0 || (year%4 == 0 && year%100 != 0)){
            special = true;//为闰年
            if(mouth > 2)
                ++sum;
        }
        for(int i = 1;i <= mouth-1;++i){
            sum = sum + map[i];
        }
        sum += day;
        printf("%d\n",sum);
    }
}