#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl '\n'
int n,m,k,T;
bool check(int y){
if(y%400==0||(y%100==0&&y%4!=0))return true;
return false;
}
int count(int y,int m,int d){
int cnt=0;
switch(m-1){
case 12:
cnt+=31;
case 11:
cnt+=30;
case 10:
cnt+=31;
case 9:
cnt+=30;
case 8:
cnt+=31;
case 7:
cnt+=31;
case 6:
cnt+=30;
case 5:
cnt+=31;
case 4:
cnt+=30;
case 3:
cnt+=31;
case 2:
if(check(y))cnt+=29;
else cnt+=28;
case 1:
cnt+=31;
}
return cnt+d;
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int y,m,d;
while(cin>>y>>m>>d){
cout<<count(y,m,d)<<endl;
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl '\n'
int n,m,k,T;
bool check(int y){
if(y%400==0||(y%100==0&&y%4!=0))return true;
return false;
}
int count(int y,int m,int d){
int bm=1;
int cnt=0;
while(bm!=m){
if(bm==1||bm==3||bm==5||bm==7||bm==8||bm==10||bm==12){
cnt+=31;
bm++;
}
else if(bm==4||bm==6||bm==9||bm==11){
cnt+=30;
bm++;
}
else if(bm==2){
if(check(y))cnt+=29;
else cnt+=28;
bm++;
}
}
return cnt+d;
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int y,m,d;
while(cin>>y>>m>>d){
cout<<count(y,m,d)<<endl;
}
return 0;
}