#include<cstdio>
bool ISrun(int n){
    if( n % 400 == 0 || n % 4 == 0 && n%100 != 0){
        return true;
    }else{
        return false;
    }
}
int main(){ 
    int year,mon,day;
    int DAYS[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    while(scanf("%d%d%d",&year,&mon,&day) != EOF){
           int today = 0;
           if(ISrun(year) == true && mon >2 || 
           ISrun(year) == true && mon == 2 && day > 28){
            today +=1; 
           }
           today +=day;
           for(int i = mon-2 ; i>=0 ;--i){
              today += DAYS[i];
           }
           printf("%d\n",today);
    }
    return 0;
}