#include <iostream>
using namespace std;
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int r[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//闰年
int main() {
    int y,n,cnt=0,mon=0,day=0;
    cin>>y>>n;
    if((y%4==0&&y%100!=0)||(y%400==0))//判断
    {
        for(int i = 1;i<=12;i++)
        {
            cnt +=r[i];
            if(cnt>=n)
            {
         //       cout<<cnt<<" "<<i<<endl;
                cnt -=r[i];//减回去
                mon = i ;
       //         cout<<cnt<<" "<<mon<<endl;
                break;
            }
        }
        day = n - cnt;
  //      cout<<day<<endl;
    }
    else {//if中的同理
    {
         for(int i = 1;i<=12;i++)
        {
            cnt +=m[i];
            if(cnt>=n)
            {
                cnt -=m[i];
                mon = i ;
         //       cout<<cnt<<" "<<mon<<endl;
                break;
            }
        }
        day = n - cnt;

    }
    }
    if(mon<10)//特判输出
    {
        cout<<y<<"-0"<<mon;
        if(day<10)cout<<"-0"<<day<<endl;
        else cout<<"-"<<day<<endl;
    }
    else {
    {
        cout<<y<<"-"<<mon;
        if(day<10)cout<<"-0"<<day<<endl;
        else cout<<"-"<<day<<endl;

    }
    }

}
// 64 位输出请用 printf("%lld")