write(sub("(12:..)","\\1 PM",sub("((0[^0]|10|11):..)","\\1 AM",scan("stdin",""))),1)