#include<stdio.h>
int leap(int year)
{
int leap;
leap=year%4==0&&year%100!=0||year%400==0;
return (leap);
}
int main()
{
int mon[]= {0,28,31,30,31,30,31,31,30,31,30};
int year,month,day;
scanf("%d%d%d",&year,&month,&day);
if(month>1)
mon[0]=31;
int i,t=0;
for(i=0; i<month-1; i++)
t=t+mon[i];
t=t+day;
if(leap(year)&&month>2)
t=t+1;
printf("%d",t);
return 0;
}