import java.util.*;//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
class word implements Comparable<word>{
int asii;
int count;
word(int asii,int count){
this.asii=asii;
this.count=count;
}
public int compareTo(word other){
if(this.count==other.count){
return other.asii-this.asii;
}
return this.count-other.count;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
ArrayList<word>list=new ArrayList<>();
String in=sc.nextLine();
for(int i=0;i<in.length();i++){
int o=0;
for(int k=0;k<list.size();k++){
if((int)in.charAt(i)==list.get(k).asii){
list.get(k).count+=1;
o=1;
break;
}
}
if(o==0){
list.add(new word((int)in.charAt(i),1));
}
}
Collections.sort(list);
for(int i=0;i<list.size();i++){
System.out.println(list.get(i).asii+" "+list.get(i).count);
}
System.out.println();
}
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
}
}