#include <iostream>
#include<cstdio>
using namespace std;
int main() {
    int year, num;
    while (scanf("%d %d", &year, &num) != EOF) {
        int a[13] = { 0, 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            a[2] = 29;
        } else {
            a[2] = 28;
        }
        int j = 0;
        int mon = 0;
        int temp = num;
        for (int i = 0; i < 13; i++) {
            j += a[i];
            if (j < num) {
                temp -= a[i];
                mon++;
            } else break;
        }

        printf("%d-%02d-%02d\n", year, mon, temp);
    }
    return 0;
}