#include <iostream>
using namespace std;

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

int main() {
    int GetMonth[2][13] = 
    {
        {0,31,28,31,30,31,30,31,31,30,31,30,31},
        {0,31,29,31,30,31,30,31,31,30,31,30,31}
    };
    int year,month,day;
    int count;
    while(scanf("%d %d",&year,&count) != EOF)
    {
        int leapyear = LeapYear(year);
        month = 1;
        while(count > GetMonth[leapyear][month])
        {
            count -= GetMonth[leapyear][month];
            ++month;
        }
        day = count;
        printf("%04d-%02d-%02d\n",year,month,day);
    }
    return 0;
}
// 64 位输出请用 printf("%lld")