/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem I. I18n                                              */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Roman Satyukov                         */
/*--------------------------------------------------------------*/
 
import java.io.*;

public class i18n_rs implements Runnable {
	private BufferedReader in;
	private PrintWriter out;
	private String[][][] words;
	private boolean[][][] bad;
	private static final String special = "-,.\"():;!? ";
	
	private boolean isAbbr(String word) {
		if (!Character.isLetter(word.charAt(0))) {
			return false;
		}
		if (!Character.isLetter(word.charAt(word.length() - 1))) {
			return false;
		}
		if (word.length() < 3) {
			return false;
		}
		word = word.substring(1, word.length() - 1);
		for (int i = 0; i < word.length(); i++) {
			if (!Character.isDigit(word.charAt(i))) {
				return false;
			}
		}
		return true;
	}
	
	private void processWord(String word) {
		if (isAbbr(word)) {
			char first = Character.toLowerCase(word.charAt(0));
			char last = Character.toLowerCase(word.charAt(word.length() - 1));
			int n = Integer.parseInt(word.substring(1, word.length() - 1));
			if (words[first - 'a'][last - 'a'][n] == null || bad[first - 'a'][last - 'a'][n]) {
				out.print(word);
				return;
			}
			String result = words[first - 'a'][last - 'a'][n];
			first = word.charAt(0);
			last = word.charAt(word.length() - 1);
			if (Character.isLowerCase(first)) {
				out.print(result);
			} else if (Character.isUpperCase(first) && Character.isLowerCase(last)) {
				out.print(first);
				out.print(result.substring(1));
			} else {
				out.print(first);
				out.print(result.substring(1, result.length() - 1).toUpperCase());
				out.print(last);
			}
			return;
		}
		out.print(word);
		if (word.length() >= 2) {
			word = word.toLowerCase();
			char first = word.charAt(0);
			char last = word.charAt(word.length() - 1);
			int n = word.length() - 2;
			if (words[first - 'a'][last - 'a'][n] != null) {
				if (words[first - 'a'][last - 'a'][n].equals(word)) {
					return;
				}
				bad[first - 'a'][last - 'a'][n] = true;
			} else {
				words[first - 'a'][last - 'a'][n] = word;
			}
		}
	}

	private void process(String cur) {
		for (int i = 0; i < cur.length(); ) {
			char ch = cur.charAt(i); 
			if (special.indexOf(ch) != -1) {
				out.print(ch);
				i++;
				continue;
			}
			StringBuffer word = new StringBuffer();
			while (Character.isLetter(ch) || Character.isDigit(ch)) {
				word.append(ch);
				if (i == cur.length() - 1) {
					i++;
					break;
				}
				ch = cur.charAt(++i);
			}
			processWord(word.toString());
		}
		out.println();
	}

	private void solve() throws IOException {
		words = new String[26][26][33];
		bad = new boolean[26][26][33];
		while (true) {
			String cur = in.readLine();
			if (cur == null) {
				break;
			}
			process(cur);
		}
	}
	
	public static void main(String[] args) {
		new Thread(new i18n_rs()).start();
	}

	public void run() {
		String problem = getClass().getName().split("_")[0];
		try {
			in = new BufferedReader(new FileReader(new File(problem + ".in")));
			out = new PrintWriter(new File(problem + ".out"));
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
