#include <iostream>
using namespace std;
int daytable[2][13]={
{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}
};
int main(){
int year,month,day;
while(cin>>year && cin>>month && cin>>day){
int leap;
leap=((year%4==0 && year%100!=0) || year%400==0);
int days=0;
for(int i=0;i<month;i++)
days+=daytable[leap][i];
days+=day;
cout<<days<<endl;
}
}