/*--------------------------------------------------------------*/
/* ACM ICPC 2007-2008                                           */
/* Northeastern European Regional Contest                       */
/* St Petersburg - Barnaul - Tashkent - Batumi, November 28, 200*/
/*--------------------------------------------------------------*/
/* Problem I. I18n                                              */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Petr Mitrichev                         */
/*--------------------------------------------------------------*/
 
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.*;

public class i18n_petr implements Runnable {
    final String TASK_ID = "i18n";
    final String IN_FILE = TASK_ID + ".in";
    final String OUT_FILE = TASK_ID + ".out";

    public static void main(String[] args) {
        Locale.setDefault(Locale.US);
        new Thread(new i18n_petr()).start();
    }

    public void run() {
        try {
            readInput();
            solve();
            writeOutput();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(57);
        }
    }

    private void solve() throws IOException {
        Map<String, String> decoding = new HashMap<String, String>();
        PrintWriter writer = new PrintWriter(OUT_FILE);

        while (true) {
            String line = reader.readLine();
            if (line == null)
                break;
            line += '#';
            String word = "";
            boolean wd = false;
            for (int i = 0; i < line.length(); ++i) {
                char ch = line.charAt(i);
                if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')) {
                    word += ch;
                    if (ch >= '0' && ch <= '9')
                        wd = true;
                } else {
                    if (word.length() > 0) {
                        String wl = word.toLowerCase();
                        if (wd) {
                            if (decoding.containsKey(wl)) {
                                String s = decoding.get(wl);
                                if (s != null) {
                                    if (Character.isUpperCase(word.charAt(0)))
                                        if (Character.isUpperCase(word.charAt(word.length() - 1)))
                                            word = s.toUpperCase();
                                        else
                                            word = Character.toUpperCase(s.charAt(0)) + s.substring(1);
                                    else
                                        word = s;
                                }
                            }
                        } else {
                            if (word.length() >= 4) {
                                String s = Character.toLowerCase(word.charAt(0)) + "" + (word.length() - 2) + Character.toLowerCase(word.charAt(word.length() - 1));
                                if (decoding.containsKey(s)) {
                                    if (!word.toLowerCase().equals(decoding.get(s)))
                                        decoding.put(s, null);
                                } else decoding.put(s, word.toLowerCase());
                            }
                        }
                        writer.print(word);
                        word = "";
                        wd = false;
                    }
                    if (ch != '#')
                        writer.print(ch);
                }
            }
            writer.println();
        }
        writer.close();
    }

    private void writeOutput() throws FileNotFoundException {
    }

    private void readInput() throws FileNotFoundException {
        reader = new BufferedReader(new FileReader(IN_FILE));
    }

    BufferedReader reader;


}
