#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
const int N=1e5+10,mod=1e6;
const int MAX = 1e8 + 10 ;
int a[] = {31,28,31,30,31,30,31,31,30,31,30,31} ;
int b[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
int y , m , d ;
void solve(int y , int m , int d){
int sum = 0 ;
if((y%4 == 0 && y %100 != 0) || y %400 == 0){
for(int i = 0 ; i< m-1 ; i++){
sum += b[i] ;
}
sum +=d ;
}else {
for(int i = 0 ; i < m-1 ; i++){
sum +=a[i] ;
}
sum +=d ;
}
cout << sum <<endl;
}
int main(){
while(cin >> y >> m >> d){
solve(y,m,d) ;
}
}