All problems

Problem 50

Character Frequency

Easy · 10 pts · String, Hash Table

Problem

You are given a string S of lowercase English letters. For every letter that appears in S, print how many times it occurs. List the letters in alphabetical order, one per line, as the letter followed by its count. Letters that do not appear in S are not printed. An array of 26 counters, one per letter, is all you need: increase the counter of each character, then print the non-zero counters from a to z.

Input

A single string S of lowercase English letters.

Output

For each distinct letter in alphabetical order, print a line: letter count.

Constraints

1 <= |S| <= 100000

Example input

banana

Example output

a 3
b 1
n 2

Explanation

"banana" contains a three times, b once and n twice. In alphabetical order that gives the lines a 3, b 1 and n 2.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Toggle Case Next: Isomorphic Strings