#include <iostream>
using namespace std;
void Next_Day(int& year, int& month, int& day) {
int dayofmonth[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) {
dayofmonth[2] = 29;
}
else {
dayofmonth[2] = 28;
}
if (day >= dayofmonth[month]) {
day = 1;
if (month == 12) {
year++;
month = 1;
}
else {
month++;
}
}
else {
day++;
}
}
int main() {
int year,day;
while (scanf("%d%d", &year, &day)!=EOF) {
int cnt = 1;
int curm = 1, curd = 1;
while (1) {
if (day == cnt) {
break;
}
else {
Next_Day(year, curm, curd);
cnt++;
}
}
printf("%04d-%02d-%02d\n", year, curm, curd);
}
return 0;
}