import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Character> alphabet_list = new ArrayList<Character>();
ArrayList<Integer> count_list = new ArrayList<Integer>();
char alp;
while(true)
{
String str = reader.readLine();
int count=0;
if(str.equals("#"))
break;
alp = str.charAt(0);
for(int i=2; i<str.length();i++)
{
if(alp-str.charAt(i)==0 || alp-str.charAt(i)==Math.abs(32))
count++;
}
alphabet_list.add(alp);
count_list.add(count);
}
for(int j=0; j<alphabet_list.size();j++)
System.out.println(alphabet_list.get(j)+" "+count_list.get(j));
}
}