#include<bits/stdc++.h>
using namespace std;
const int N=105;
struct node{
int rank,num;
string name,help;
}q[N];
int m,n;
bool cmp(node a,node b)
{
if(a.num==b.num)
return a.rank<b.rank;
return a.num>b.num;
}
bool check(string s,int b)
{
if(s[b]=='s'&&s[b+1]=='o'&&s[b+2]=='s') return 1;
return 0;
}
int main()
{
freopen("save.in","r",stdin);
freopen("save.out","w",stdout);
scanf("%d",&n);
for(int i=0;i<n;i++)
{
q[i].rank=i;
cin>>q[i].name>>q[i].help;
for(int j=0;j<q[i].help.size()-2;j++)
{
if(check(q[i].help,j))
{
q[i].num++;
}
}
}
sort(q,q+n,cmp);
m=q[0].num;
for(int i=0;i<n;i++)
{
if(q[i].num<m) break;
cout<<q[i].name;
putchar(' ');
}
printf("\n%d",m);
return 0;
}