#include <stdio.h>
#include <stdlib.h>
typedef struct calender
{
int year;
int month;
int day;
}Calender;
int main()
{ Calender rili;
scanf("%d %d %d",&rili.year,&rili.month,&rili.day);
if((((rili.year)%40)&&(rili.year)%100!=0)||(((rili.year)%1000)&&(rili.year)%400==0))
{switch(rili.month)
{
case 1:printf("%d",rili.day);break;
case 2:printf("%d",rili.day+31);break;
case 3:printf("%d",rili.day+60);break;
case 4:printf("%d",rili.day+91);break;
case 5:printf("%d",rili.day+121);break;
case 6:printf("%d",rili.day+152);break;
case 7:printf("%d",rili.day+182);break;
case 8:printf("%d",rili.day+213);break;
case 9:printf("%d",rili.day+244);break;
case 10:printf("%d",rili.day+274);break;
case 11:printf("%d",rili.day+305);break;
case 12:printf("%d",rili.day+335);break;
}}
else
{switch(rili.month)
{
case 1:printf("%d",rili.day);break;
case 2:printf("%d",rili.day+31);break;
case 3:printf("%d",rili.day+59);break;
case 4:printf("%d",rili.day+90);break;
case 5:printf("%d",rili.day+120);break;
case 6:printf("%d",rili.day+151);break;
case 7:printf("%d",rili.day+181);break;
case 8:printf("%d",rili.day+212);break;
case 9:printf("%d",rili.day+243);break;
case 10:printf("%d",rili.day+273);break;
case 11:printf("%d",rili.day+304);break;
case 12:printf("%d",rili.day+334);break;
}}
}