import Data.List
import Control.Arrow

main = getContents >>= print . freq

freq = map (head &&& length) . group . sort