#include<stdio.h>
int main(){
int t;
int h=0,m=0,s=0;
scanf("%d",&t);
h=t/3600;
m=(t-h*3600)/60;
s=t-h*3600-m*60;
if(h>=0&&h<12)
printf("%02d:%02d:%02d am",h,m,s);
else if(h>=12&&h<13)
printf("%02d:%02d:%02d midnoon",h,m,s);
else if(h>=13)
printf("%02d:%02d:%02d pm",h-12,m,s);
return 0;
}