#include <iostream>
#include <cstdio>

using namespace std;

int m1[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int m2[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int y;
    int n;
    while(scanf("%d %d",&y,&n)!=EOF){
        int m=0;
        int d;
        d=n;
        if((y%4==0&&y%100!=0)||y%400==0){
            for(int i=0;i<12;++i){
                d=d-m1[i];
                m++;
                if(d<=m1[i+1]){
                    break;
                }
            }

        }else{
            for(int i=0;i<12;++i){
                d=d-m2[i];
                m++;
                if(d<=m2[i+1]){
                    break;
                }
            }
        }
        printf("%d-%02d-%02d\n",y,m,d);//这里场宽为2,%02d,烦
    }
}