#include <iostream>
using namespace std;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main() {
    int year,mon,day;
    while (cin >> year >> mon>>day) { // 注意 while 处理多个 case
        int sum=0;
        if(year%4==0 || year%100==0){
            if(mon>2)sum++;
            for(int i=1;i<mon;i++)sum+=month[i];
            sum=sum+day;
        }else {
            for(int i=1;i<mon;i++)sum+=month[i];
            sum=sum+day;
        }

        cout<<sum<<endl;
    }
}
// 64 位输出请用 printf("%lld")