//ISC 2003
import java.io.*;
public class TimeInWords
{   public static void timeInWords()throws IOException
    {   String inWords[]={"", "one", "two", "three", "four", "five", "six","seven", "eight", "nine","ten",
        "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen", "twenty",
         "twenty one", "twenty two", "twenty three", "twenty four", "twenty five", "twenty six","twenty seven", "twenty eight", "twenty nine"};
         BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
         System.out.println("Enter Hours ");
         int h=Integer.parseInt(br.readLine());
         System.out.println("Enter Minutes ");
         int m=Integer.parseInt(br.readLine());
         if(m==0)
            System.out.println(inWords[h]+" 'O' Clock");
         else if(m==15)
            System.out.println("Quarter past "+inWords[h]);
         else if(m==30)
            System.out.println("Half past "+inWords[h]);
         else if(m==45)
            System.out.println("Quarter to "+inWords[h+1]);
         else if(m>30) 
            System.out.println(inWords[60-m]+" minutes to "+inWords[h+1]);
        else
            System.out.println(inWords[m]+" minutes past "+inWords[h]);
    }//main
    public static void main(String args[])throws IOException
    {   timeInWords();
    }
}//class

