import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int y=0; int n=0; int[] month=new int[]{31,28,31,30,31,30,31,31,30,31,30,31}; while(sc.hasNext()){ y=sc.nextInt(); n=sc.nextInt(); int mon=0; int day=0; if(!isTrueYear(y)){ if(n>=1&&n<=31){ mon=1; day=n; }else if(n>31&&n<=59){ mon=2; day=n-31; }else if(n>59&&n<=90){ mon=3; day=n-59; }else if(n>90&&n<=120){ mon=4; day=n-90; }else if(n>120&&n<=151){ mon=5; day=n-120; }else if(n>151&&n<=181){ mon=6; day=n-151; }else if(n>181&&n<=212){ mon=7; day=n-181; }else if(n>212&&n<=243){ mon=8; day=n-212; }else if(n>243&&n<=273){ mon=9; day=n-243; }else if(n>273&&n<=304){ mon=10; day=n-273; }else if(n>304&&n<=334){ mon=11; day=n-304; }else if(n>334&&n<=365){ mon=12; day=n-334; } }else{ if(n>=1&&n<=31){ mon=1; day=n; }else if(n>31&&n<=60){ mon=2; day=n-31; }else if(n>60&&n<=91){ mon=3; day=n-60; }else if(n>91&&n<=121){ mon=4; day=n-91; }else if(n>121&&n<=152){ mon=5; day=n-121; }else if(n>152&&n<=182){ mon=6; day=n-152; }else if(n>182&&n<=213){ mon=7; day=n-182; }else if(n>213&&n<=244){ mon=8; day=n-213; }else if(n>244&&n<=274){ mon=9; day=n-244; }else if(n>274&&n<=305){ mon=10; day=n-274; }else if(n>305&&n<=335){ mon=11; day=n-305; }else if(n>335&&n<=366){ mon=12; day=n-335; } } if(mon<10){ if(day<10){ System.out.println(y+"-0"+mon+"-0"+day); }else{ System.out.println(y+"-0"+mon+"-"+day); } }else{ if(day<10){ System.out.println(y+"-"+mon+"-0"+day); }else{ System.out.println(y+"-"+mon+"-"+day); } } } } static boolean isTrueYear(int n){ if(n%100==0){ if(n%400==0)return true; else return false; } else if(n%4==0){ return true; }else{ return false; } } }