#include <iostream>
using namespace std;
int h,m;
char O[11][100] = {"ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
char M[19][150] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
char A[2][12]   = {"quarter", "half"};
void trans()
{
    if(m==60)
        cout<<M[h]<<" o'clock";
    else
        if(m==0)
            cout<<M[h-1]<<" o'clock";
    else
        if(m==1)
            cout<<M[m-1]<<" minute "<<"past "<<M[h-1];
    if(m>1 && m<20 && m!= 15)
        cout<<M[m-1]<<" minutes "<<"past "<<M[h-1];
    if(m==15)
        cout<<A[0]<<" minutes "<<"past "<<M[h-1];
    else
        if(m==30)
            cout<<A[1]<<" minutes "<<"past "<<M[h-1];
    else
        if(m==45)
            cout<<A[0]<<" minutes "<<"past "<<M[h-1];
    if(m>20 && m<30)
        cout<<O[m/10%10-1]<<" "<<M[m%10-1]<<" minutes past "<<M[h-1];
    else
        if(m>30 && m!=45 && m!=60){
            if(60-m<20)
                cout<<M[60-m-1]<<" minutes to "<<M[h-1];
            else
                cout<<O[(60-m)/10%10-1]<<" "<<M[(60-m)%10-1]<<" minutes to "<<M[h];
        }
}
int main()
{
    do{
        cout<<"H = ";
        cin>>h;
        if(h<0 || h>12)
            cout<<"Ati introdus o ora gresita!"<<'\n';;
    }while(h<0 || h>12);
    do{
        cout<<"M = ";
        cin>>m;
        if(m<0 || m>60)
            cout<<"Ati introdus minutele gresit!"<<'\n';
    }while(m<0 || m>60);
    trans();
    return 0;
}