#include <iostream>
using namespace std;

int main() {
    int year,month,day,run;
    int yy[2][12]={
        {31,28,31,30,31,30,31,31,30,31,30,31},
        {31,29,31,30,31,30,31,31,30,31,30,31}
    };
    while(cin>>year>>month>>day){
        if((year%4==0&&year%100!=0)||(year%400==0))run=1;
        else run=0;
        int number=0;
        int i=0;
        while(month>i+1){
            number+=yy[run][i];
            i++;
        }
        number+=day;
        cout<<number;
    }

}