#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int year,n;
	int i;
	int mday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    while(scanf("%d%d",&year,&n)!=EOF){
	if(year%400==0||year%4==0&&year%100!=0)
	{
		mday[2]=29;
	}
	else
	    {
		mday[2]=28;}
	int month=1;
	int day=1;
	for(i=0;i<n-1;i++)
	{
		day++;
		if(day>mday[month])
		{
			day=1;
			month++;
		 if(month>12)
		   {
			month=1;
			day=1;
			year++;
		   }
		}
		
	 } 
	 printf("%04d-%02d-%02d\n",year,month,day);
	
}
}