#include <iostream>
using namespace std;
bool IsLeap(int year){
    if (year%4==0||(year%4==0&&year%100!=0))
        return true;

return false;
}
int main()

{   int A[]={31,28,31,30,31,30,31,31,30,31,30,31};
    int year,month,day;

   while(scanf("%d %d %d",&year,&month,&day)!=EOF){
        int seq=0;
    if(IsLeap(year)){
        A[1]=29;
    }else{
        A[1]=28;
    }
    while(month>1){
           seq+=A[month-2];
        month--;
    }
    printf("%d\n",seq+day);
   }
}