#include<bits/stdc++.h>
using namespace std;
char help[211],name[31][111];
//struct
int n,j,mj,z,m,maxn[31];
int main()
{
cin>>m;
z=1;
for(int k=1;k<=m;k++)
{
memset(help,0,sizeof(help));
j=0;
cin>>name[k];
cin>>help;
int i=0;
int t;
while(help[i]!=0)
{
if(help[i]=='s'&&help[i+1]=='o'&&help[i+2]=='s')
{
j++;
}
i++;
if(i==215)
{
return 0;
}
}
if(j>mj)
{
mj=j;
z=1;
maxn[z]=k;
}
else if(j==mj)
{
z++;
maxn[z]=k;
}
}
for(int i=1;i<=z;i++)
{
cout<<name[maxn[i]]<<" ";
}
cout<<endl;
cout<<mj;
return 0;
}