import java.util.*;

public class histograma
{

  public static void main(String args[])
    {
	
	Hashtable words = new Hashtable();
	int c = ' ';
	
	while (c >= 0)
	    {
	      try {
		StringBuffer w = new StringBuffer();
		do
		    {
			c = System.in.read();
			if (Character.isUpperCase((char)c))
			    c = Character.toLowerCase((char)c);
			if (Character.isLowerCase((char)c))
			    w.append((char)c);
			else
			    break;
		    }
		while (true);
		
		if (w.length() > 0)
		    {
			String s = w.toString();
			if (words.containsKey(s))
			    {
				Integer cnt = (Integer)words.get(s);
				words.put(s, new Integer(cnt.intValue()+1));
			    }
			else
			    {
				words.put(s, new Integer(1));
			    }
			
		    }
	      }
	      catch (java.io.IOException e) {c = -1; System.out.println("FIN..."); }
	    }
	
	
	Vector concord = new Vector();
	for (Enumeration e = words.keys(); e.hasMoreElements();)
	    {
		String w = (String)e.nextElement();
		Integer cnt = (Integer)words.get(w);
		concord.add (new WordCounts(w, cnt.intValue()));
	    }
	
	for (int i = 1; i < concord.size(); ++i)
	    {
	      WordCounts element = (WordCounts)concord.get(i);
	      int j = i - 1;
	      while ((j >= 0)
		     &&
		     (element.compareTo((WordCounts)concord.get(j)) < 0))
		{
		  concord.set(j+1, concord.get(j));
		  j--;
		}
	      concord.set(j+1, element);
	    }
	
	
	for (int j = 0; j < concord.size(); j++)
	  {
	    WordCounts wc = (WordCounts)concord.get(j);
	    System.out.println (wc.word + ' ' + wc.count);
	  }
	
    }
};
