#include <stdio.h>

int main(){
    int year,month,day;
    int list1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int list2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    while(scanf("%d %d %d",&year,&month,&day)!=EOF){
        int daynum=0;
        if((year%4==0 && year%100 !=0) || year%400==0){
            for (int i = 1;i<month;i++){
                daynum=daynum+list2[i];
            }
            daynum=daynum+day;
        }
        else{
            for (int i = 1;i<month;i++){
                daynum=daynum+list1[i];
            }
            daynum=daynum+day;
        }
        printf("%d",daynum);
    }
}