#include<stdio.h>
int main()
{
    int year,month,day,time=0,i;
    int a[12] ={31,28,31,30,31,30,31,31,30,31,30,31};
    while((scanf("%d %d %d",&year,&month,&day))!=EOF)
    {
       
        if(month>2&&(year%4==0&&year%100!=0||year%400==0))//判断是否闰年
        {for(i=0;i<month-1;i++)
            {

                time = a [i]+time;
                
            }
         printf("%d\n",time+day+1);
         time = 0;
        }
             else
        {for(i=0;i<month-1;i++)
            {
                time = a [i]+time;
                
            }
         printf("%d\n",time+day);
         time = 0;
    }
        }
    return 0;
}