#include<stdio.h>
int sort(int year)
{int aa;
if((year%4==0&&year%100!=0)||(year%400==0))
aa=1;
else aa=0;
return(aa);
}
int main()
{int year,yue,ri,day,flag;
scanf("%d,%d,%d",&year,&yue,&ri);
flag=sort(year);
switch(yue-1)
{
case 0:day=0;break;
case 1:day=31;break;
case 2:day=59;break;
case 3:day=90;break;
case 4:day=120;break;
case 5:day=151;break;
case 6:day=181;break;
case 7:day=212;break;
case 8:day=243;break;
case 9:day=273;break;
case 10:day=304;break;
case 11:day=334;break;
default:printf("error\n");
}
if(flag==1)
day=day+ri+1;
else day=day+ri;
printf("%dth",day);
return 0;
}