/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem I. I18n                                              */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Roman Elizarov                         */
/*--------------------------------------------------------------*/
 
/*
    Solution for NEERC'2007 Problem I: I18n
    (C) Roman Elizarov
    Note: this solution attempts to check correctness of the input
*/

import java.io.*;
import java.util.*;

public class i18n_re {

	public static void main(String[] args) throws Exception {
		new i18n_re().go();
	}

	final Map<String,String> decode = new HashMap<String, String>();

	void go() throws Exception {
		// read input & solve on-line
		BufferedReader in = new BufferedReader(new FileReader("i18n.in"));
		PrintWriter out = new PrintWriter("i18n.out");
		int lc = 0;
		String line;
		while ((line = in.readLine()) != null) {
			lc++;
			assert lc <= 1000;
			assert line.length() <= 80 && line.length() > 0;
			assert line.charAt(line.length() - 1) != ' ';
			int wc = 0;
			StringBuilder word = new StringBuilder();
			for (int i = 0; i < line.length(); i++) {
				char c = line.charAt(i);
				if (isLetter(c) || isDigit(c))
					word.append(c);
				else if (c == ' ' || c == '-' || c == ',' || c == '.' || c == '"' || c == '(' || c == ')' ||
						c == ':' || c == ';' || c == '!' || c == '?')
				{
					wc += dumpWord(out, word);
					out.print(c);
				}
			}
			wc += dumpWord(out, word);
			out.println();
			assert wc > 0;
		}
		in.close();
		out.close();
	}

	private boolean isDigit(char c) {
		return c >= '0' && c <= '9';
	}

	private boolean isLetter(char c) {
		return c >= 'a' && c <= 'z' || isUpperCase(c);
	}

	private boolean isUpperCase(char c) {
		return c >= 'A' && c <= 'Z';
	}

	private int dumpWord(PrintWriter out, StringBuilder word) {
		if (word.length() == 0)
			return 0;
		boolean abbr = false;
		int n = word.length();
		for (int i = 0; i < n; i++) {
			char c = word.charAt(i);
			if (isDigit(c))
				abbr = true;
		}
		String wl = word.toString().toLowerCase(Locale.US);
		if (abbr) {
			assert n >= 3 && n <= 4;
			assert isLetter(word.charAt(0)) && isLetter(word.charAt(n - 1));
			int k = Integer.parseInt(word.substring(1, n - 1));
			assert k >= 2 && k <= 30 && word.charAt(1) != '0';
			String dl = decode.get(wl);
			if (dl == null)
				out.print(word);
			else {
				StringBuilder d = new StringBuilder(dl);
				if (isUpperCase(word.charAt(0)))
					d.setCharAt(0, Character.toUpperCase(d.charAt(0)));
				if (isUpperCase(word.charAt(n - 1))) {
					assert isUpperCase(word.charAt(0));
					for (int i = 1; i < d.length(); i++)
						d.setCharAt(i, Character.toUpperCase(d.charAt(i)));
				}
				out.print(d);
			}
		} else {
			assert n >= 1 && n <= 32;
			out.print(word);
			boolean ulast = isUpperCase(word.charAt(n - 1));
			for (int i = 1; i < n; i++)
				assert ulast == isUpperCase(word.charAt(i));
			if (ulast)
				assert isUpperCase(word.charAt(0));
			if (n > 3) {
				String al = wl.charAt(0) + Integer.toString(n - 2) + wl.charAt(n - 1);
				String dl = decode.get(al);
				if (dl == null)
					decode.put(al, wl);
				else if (!dl.equals(wl))
					decode.put(al, al);
			}
		}
		word.setLength(0);
		return 1;
	}
}

