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

/**
 * i18n_pm to be documented :TODO:.
 *
 * @author Pavel Mavrin
 * @version $Id$
 */
public class i18n_pm implements Runnable {

    Map<String, String> abbrs = new HashMap<String, String>();

    private void solve() throws FileNotFoundException {
        Scanner in = new Scanner(new File("i18n.in"));
        PrintWriter out = new PrintWriter("i18n.out");
        while (in.hasNextLine()) {
            String line = in.nextLine();
            while (line.length() > 0) {
                int i = 0;
                while (i < line.length() && isWordPart(line.charAt(i))) i++;
                if (i == 0) {
                    if (" .,-\"():;!?".indexOf(line.charAt(0)) < 0) {
                        throw new RuntimeException("Invalid character in input file: \'" + line.charAt(0) + "\'");
                    }
                    out.print(line.charAt(0));
                    line = line.substring(1);
                } else {
                    out.print(getWord(line.substring(0, i)));
                    line = line.substring(i);
                }
            }
            out.println();
        }
        in.close();
        out.close();
    }

    private String getWord(String s) {
        checkWord(s);
        if (s.length() > 2 && Character.isDigit(s.charAt(1))) {
            return extend(s);
        } else {
            if (s.length() > 3) {
                registerWord(s);
            }
            return s;
        }
    }

    private String extend(String abbr) {
        String s = abbrs.get(abbr.toLowerCase());
        if (s == null) {
            return abbr;
        } else {
            if (Character.isUpperCase(abbr.charAt(0))) {
                if (Character.isUpperCase(abbr.charAt(abbr.length() - 1))) {
                    return s.toUpperCase();
                } else {
                    return "" + Character.toUpperCase(s.charAt(0)) + s.substring(1);
                }
            } else {
                return s;
            }
        }
    }

    private void checkWord(String s) {
        if (s.matches("[a-z]+")) return;
        if (s.matches("[A-Z]+")) return;
        if (s.matches("[A-Z][a-z]+")) return;
        if (s.matches("[a-zA-Z][1-9][0-9]?[a-zA-Z]")) {
            int i = Integer.parseInt(s.substring(1, s.length() - 1));
            if (i >= 2 && i <= 30) return;
        }
        throw new RuntimeException("Invalid word in input file: \"" + s + "\"");
    }


    private void registerWord(String s) {
        s = s.toLowerCase();
        String abbr = "" + s.charAt(0) + (s.length() - 2) + s.charAt(s.length() - 1);
        String q = abbrs.get(abbr);
        if (q == null) {
            abbrs.put(abbr, s);
        } else if (!q.equals(s)) {
            abbrs.put(abbr, abbr);
        }
    }

    private boolean isWordPart(char c) {
        return Character.isDigit(c) || Character.isLetter(c);
    }

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

    public static void main(String[] args) {
        new Thread(new i18n_pm()).start();
    }
}
