import java.util.*;

public class QuizArrayList {
	
	public static void main(String[] args) {
		
		// Question 1: Create the array list.
		ArrayList<String> thesestrings = new ArrayList<String>();
		
		// Question 2: Read in all of the strings.
		Scanner stdin = new Scanner(System.in);
		System.out.println("Enter strings, end with DONE.");
		String s = stdin.next();
		while (!s.equals("DONE")) {
  			thesestrings.add(s);
  			s = stdin.next();
		}

		// Question 3: Sort these strings.
		Collections.sort(thesestrings);
		
		// Question 4: Print them out.
		for (int i=0; i<thesestrings.size(); i++) {
			System.out.println(thesestrings.get(i));
		}
		
		// Question 5: Print out the number of strings.
		System.out.println(thesestrings.size());

		// Question 6: Remove the last one and print it.
		System.out.println(thesestrings.remove(thesestrings.size()-1));
		
		// Proves our remove worked.
		System.out.println("Now we have "+thesestrings.size()+" items left.");
		
		// Question 7: Clear everything!
		thesestrings.clear();
		
		// Proves our clear worked.
		System.out.println("Finish with "+thesestrings.size()+" items left.");

	}
}