#include <iostream>
using namespace std;
//              1 2   3  4  5  6  7  8  9 10 11 12
int arr[27]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main() {
    int year,month,day;
    while(cin>>year>>month>>day){
        if(year%400==0||(year%4==0&&year%100!=0)){
            arr[2]=29;
        }
        int sum = 0;
        for(int i=0;i<month;++i){
            sum+=arr[i];
        }
        sum+=day;
        cout<<sum<<endl;
    }
}
// 64 位输出请用 printf("%lld")