public class Solution { public static Map<Integer, String> map = new HashMap<Integer, String>(); static { map.put(0,"ноль"); map.put(1,"один"); map.put(2,"два"); map.put(3,"три"); map.put(4,"четыре"); map.put(5,"пять"); map.put(6,"шесть"); map.put(7,"семь"); map.put(8,"восемь"); map.put(9,"девять"); map.put(10,"десять"); map.put(11,"одиннадцать"); map.put(12,"двенадцать"); } public static void main(String[] args) throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); BufferedReader file = new BufferedReader(new FileReader(r.readLine())); String line = ""; Pattern patern = Pattern.compile("(?<![\\d\\w])\\d{1,2}(?!\\d)"); while (file.ready()){ line = file.readLine(); Matcher m = patern.matcher(line); StringBuffer sb = new StringBuffer(line.length()); while (m.find()){ int n = Integer.parseInt(m.group()); m.appendReplacement(sb, Matcher.quoteReplacement(map.get(n))); } m.appendTail(sb); System.out.println(sb.toString()); } r.close(); file.close(); } }