import java.util.Scanner;import java.text.*;class D{
	/* I had to accept input via stdin, so I wrote another main method that passes values to the 
	 * main method seen in my answer. The main method in my answer is now called MAIN.
	 * This acts exactly the same way that it would from inserting command line arguments.
	 */
	public static void main(String[]a){MAIN(new String[]{new Scanner(System.in).nextLine()});}
	public static void MAIN(String[]a){long y=new Long(a[0]);int i=0;for(;!s(y).equals(s(y+(++i))););System.out.printf("Advance Happy New Year, %d (%s)",y+i,s(y+i));}static String s(long y){try{return new SimpleDateFormat("E").format(new SimpleDateFormat("d/M/yyyy").parse("1/1/"+y));}catch(Exception e){}return"";}}