#include"iostream"
using namespace std;
void input(int &hours24,int &minutes)
{
cin>>hours24>>":">>minutes;
}
void convert(int&hours,char&M)
{
if(hours-12<0)AMPM='A';
else
{
hours-=12;
AMPM='P';
}
}
void output(int hours,int minutes,char AMPM)
{
cout<<hours<<":"<<minutes<<AMPM<<endl;
}
void main()
{
int hours24,minutes;
char AMPM;
input(&hours24,&minutes);
convert(&hours24,&M);
output(hours24,minutes, AMPM);
}
#include<iostream>
using namespace std;
void input(int &hours24,int &minutes)
{
char tmp;
cin>>hours24>>tmp>>minutes;
}
void convert(int&hours,char&M)
{
if(hours-12<0)AMPM='A';
else
{
hours-=12;
AMPM='P';
}
}
void output(int hours,int minutes,char AMPM)
{
cout<<hours<<":"<<minutes<<AMPM<<endl;
}
int main()
{
int hours24,minutes;
char AMPM;
input(hours24,minutes);
convert(hours24,AMPM);
output(hours24,minutes, AMPM);
}