#include<stdio.h>
//公历年份是4的倍数,且不是100的倍数的
int main(){
int year, month, day;
while(scanf("%d", &year) != EOF){
scanf("%d", &month);
scanf("%d", &day);
int all = 0;
int run = 0;
if(year%4==0 && year%100 != 0)run = 1;
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for(int i=0; i<month-1; i++){
all+=days[i];
}
all += day;
if(month>2 && run)all+=1;
printf("%d\n", all);
}
}