#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
class Freq{
public:
Freq(char ansii, int count){
this->ansii = ansii;
this->count = count;
}
char ansii;
int count;
};
bool FreqCompare (const Freq &a, const Freq &b){
if (a.count!=b.count){
return a.count<b.count;
} else {
return a.ansii>b.ansii;
}
}
int main(int argc, char *argv[]){
map<char, int> m;
map<char, int>::iterator it;
vector<Freq> freq;
string line;
bool firstTime=true;
while (getline(cin, line)){
m.clear();
freq.clear();
for (int i=0; i<line.size(); ++i){
it = m.find(line[i]);
(it == m.end()) ? m[line[i]]=1 : m[line[i]]++;
}
for (it=m.begin(); it!=m.end(); ++it){
freq.push_back(Freq(it->first, it->second));
}
sort(freq.begin(), freq.end(), FreqCompare);
firstTime ? firstTime=false : cout << endl ;
for (int i=0; i<freq.size(); ++i){
cout << (size_t) freq[i].ansii << " " << freq[i].count << endl;
}
}
return 0;
}