#include <iostream>
using namespace std;
int main() {
    int year,month,day;
    while(cin>>year>>month>>day){
        int arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        if((year%400==0)||(year%100!=0&&year%4==0))
            arr[2]++;
        //开始判断
        for(int i =1;i<month;i++)
            day+=arr[i];
        cout<<day<<endl;
    }
}
// 64 位输出请用 printf("%lld")