#include<iostream>
using namespace std;
const int Y=3000,M=12,D=31;
int y,m,d,sum=0;
int year[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int r_year[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int main()
{
cin>>y>>m>>d;
if((y%4==0 && y%100!=0)||y%400==0)
{
for(int i=0;i<m-1;i++)
{
sum+=r_year[i];
}
sum+=d;
}
else
{
for(int i=0;i<m-1;i++)
{
sum+=year[i];
}
sum+=d;
}
cout<<sum<<endl;
return 0;
}