import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;

public class StringFlyweight 
{
  public static void main(String[] args)
    throws Exception
  {
    String fName = args[0];

    Scanner scanner = new Scanner(new File(fName) );

    ArrayList<String> words = new ArrayList<String>();

    while ( scanner.hasNext() )
    {
      String word = scanner.next();

      if (word.length()>1)
	words.add ( word.substring(0,word.length()-2) + word.charAt(word.length()-1));
      else
	words.add(word);
    }

    
    System.out.println("Press enter to continue");
    (new Scanner(System.in)).nextLine();

    for (int i=0 ; i<words.size() ; i++)
      words.set(i, words.get(i).intern() );

    System.gc();

    System.out.println("Press enter to continue");
    (new Scanner(System.in)).nextLine();


  }



}