#include<stdio.h>

	struct date{
		int day,m,year;
	};
int day_of_year(struct date *p);
int main()
	{

		int m,day,year;
		int i,s=0;
		int month[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
		scanf("%d%d%d",&year,&m,&day);
		if(year%4==0&&year%100!=0||year%400==0)
			month[2]=29;
		else
			month[2]=28;
		for(i=0;i<m;i++)
		{
			s=s+month[i];
		}
		s=s+day;
		printf("%d",s);
		return 0;
	}