#include <iostream>
using namespace std;

//这是第N个月的总天数
int Days[13] = {0,31,59,90,120,151,181,212,243,273,304,334,365};

bool IsLeapYear(int _year)
{
    if ((((_year%4==0) && (_year%100 != 0)) || (_year%400 == 0)))
        return true;
    else
        return false;
}

int month = 1;

int main() {
    int year, day,RealDay;
    while(cin >> year >> day)
    {
        for(month=1;day>Days[month];month++);

        //这里单独处理闰年2月的特殊情况
        if(IsLeapYear(year) && month > 2)
        {
            RealDay = day - Days[month-1] - 1;
            if(RealDay == 0)
            {
                RealDay = 29;
                month -=1;
            }
        }
        else
            RealDay = day - Days[month-1];
        
        printf("%04d-%02d-%02d\n",year,month,RealDay);
    }

    
}