#include<stdio.h>
int main()
{
int Y, M, D;
char a, b;
scanf("%d%c%d%c%d", &Y, &a, &M, &b, &D);
if ((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) {
switch (M) {
case 1:
printf("%d", D);
break;
case 2:
printf("%d", 31 + D);
break;
case 3:
printf("%d", 60 + D);
break;
case 4:
printf("%d", 91 + D);
break;
case 5:
printf("%d", 121 + D);
break;
case 6:
printf("%d", 152 + D);
break;
case 7:
printf("%d", 182 + D);
break;
case 8:
printf("%d", 213 + D);
break;
case 9:
printf("%d", 244 + D);
break;
case 10:
printf("%d", 274 + D);
break;
case 11:
printf("%d", 305 + D);
break;
case 12:
printf("%d", 335 + D);
break;
default:
printf("您输入错误。");
}
} else {
switch (M) {
case 1:
printf("%d", D);
break;
case 2:
printf("%d", 31 + D);
break;
case 3:
printf("%d", 59 + D);
break;
case 4:
printf("%d", 90 + D);
break;
case 5:
printf("%d", 120 + D);
break;
case 6:
printf("%d", 151 + D);
break;
case 7:
printf("%d", 181 + D);
break;
case 8:
printf("%d", 212 + D);
break;
case 9:
printf("%d", 243 + D);
break;
case 10:
printf("%d", 273 + D);
break;
case 11:
printf("%d", 304 + D);
break;
case 12:
printf("%d", 334 + D);
break;
default:
printf("您输入错误。");
}
}
return 0;
}