#include<iostream>
using namespace std;
#define ISLEAP(x) (0==x%4 && 0!= x%100)|| (0==x%400) >0?1:0
int monthOfDay[13][2]=
{
0,0,
31,31,
28,29,
31,31,
30,30,
31,31,
30,30,
31,31,
31,31,
30,30,
31,31,
30,30,
31,31
};
int main()
{
int Y,M,D;
int flag =0;
int cnt = 0;
while(cin >> Y >>M >> D)
{
cnt =0;
flag =0;//非瑞年
if(ISLEAP(Y))
{
flag = 1; //瑞年
}
for(int i=1; i<M; i++)
{
cnt +=monthOfDay[i][flag];
}
cout << cnt+D << endl;
}
return 0;
}
/**************************************************************
Problem: 1070
User: itswyy
Language: C++
Result: Accepted
Time:130 ms
Memory:1520 kb
****************************************************************/