#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int word[30];
int maxn;
int main()
{
int n=4;
while(n--){
string a;
getline(cin,a);
for(int i=0;i<a.size();i++){
if(a[i]>='A'&&a[i]<='Z'){
word[a[i]-'A']++;
}
}
}
for(int i=0;i<26;i++){
maxn=max(maxn,word[i]);
}
for(int i=maxn;i>0;i--){
printf("%2d ",i);
for(int j=0;j<26;j++){
if(word[j]>=i){
cout<<"*";
}else{
cout<<" ";
}
if(j!=25){
cout<<" ";
}
}
cout<<endl;
}
cout<<" 0 ";
for(int i=0;i<26;i++){
printf("%c",'A'+i);
if(i!=25){
cout<<" ";
}
}
return 0;
}