#include <bits/stdc++.h>
using namespace std;
/*
* Complete the 'timeConversion' function below.
*
* The function is expected to return a STRING.
* The function accepts STRING s as parameter.
*/
string timeConversion(string s) {
string mil;
int time = (s.at(0) - '0') * 10 + (s.at(1) - '0');
if (s.find('P') != string::npos)
{
if (time >= 1 && time <= 11)
{
time += 12;
}
}
else if (s.find('A') != string::npos)
{
if (time == 12)
{
time = 0;
}
}
else
{
cout << "Wrong format" << endl;
}
string timeS = to_string(time);
if (time < 10)
{
timeS = '0' + timeS;
}
mil = timeS + ":" + s.at(3)+s.at(4) + ":" + s.at(6)+s.at(7);
return mil;
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string s;
getline(cin, s);
string result = timeConversion(s);
fout << result << "\n";
fout.close();
return 0;
}