# include<iostream>
using namespace std;
int main()
{
int year,month,ri,i,d1=0,d,d2,day,j;
int a[12]={0,31,59,90,120,151,181,212,243,273,304,334};
int b[12]={0,31,60,91,121,152,182,213,244,274,305,335};
cin>>year>>month>>ri;
d=0;d1=0;d2=0;
if((year%4==0&&year%100!=0)||(year%400==0))
{ d1=b[month-1]+ri;
d=366-d1;
}
else
{
d1=a[month-1]+ri;
d=365-d1;
}
i=year+1;
while(d<=10000)
{
if((i%4==0&&i%100!=0)||(i%400==0))
{ d=d+366;
if(d>10000){d=d-366;break;}
}
else{
d=d+365;
if(d>10000){d=d-365;break;}
}
i++;
}
d2=10000-d;
if(d2==0)
{
cout<<i-1<<"-"<<12<<"-"<<31;
}
else
{ cout<<i<<"-";
if((i%4==0&&i%100!=0)||(i%400==0))
{ if(d2<=b[11])
{for(j=0;j<11;j++)
{
if(d2>=b[j]&&d2<b[j+1])
{cout<<j+1<<"-";
day=d2-b[j];
}
}
} else
{ cout<<12<<"-";
day=d2-335;}
cout<<day;
}
else
{ if(d2<=a[11])
{
for(j=0;j<11;j++)
{
if(d2>=a[j]&&d2<=a[j+1])
{cout<<j+1<<"-";
day=d2-a[j];
}
}
}
else {cout<<12<<"-";day=d2-334;}
cout<<day;
}
}
return 0;
}