#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef struct _node{ int ascii; int count; } Node;
bool compare (Node a,Node b){ if (a.count == b.count) return b.ascii < a.ascii; else return a.count < b.count; }
int main () {
string s; int first=1;
while (getline(cin,s))
{ if (first ==1){ first=0; }
else { cout << endl; }
int c[257]={0}; Node mynode[257];
for(int i=0;i<s.length();i++){ c[s[i]]++; }
int k=0;
for(int i=0;i<257;i++)
{ if (c[i]>0){ mynode[k].ascii=i; mynode[k].count=c[i]; k++; } }
sort(mynode,mynode+k,compare);
for(int i=0;i<k;i++){ cout << mynode[i].ascii << " "<<mynode[i].count <<endl; }
}
}