#include <bits/stdc++.h>
using namespace std;
int a,b[10000],big,sc;
string d[100001],c,s2c[1000001];
int main(){
cin>>a;
for(int o=1;o<=a;o++){
cin>>d[o];
cin>>c;
for(int i=1;i<=c.length();i++){
if(c[i-1]=='s'){
if(c[i]=='o'){
if(c[i+1]=='s'){
b[o]++;
}
}
}
}
}
int i=1;
for(int o=1;o<=a;o++){
if(b[o]>=big){
big=b[o];
s2c[i]=d[o];
i++;
}
}
for(int pp=1;pp<=i;pp++)
cout<<s2c[pp]<<" ";
cout<<endl<<big;
return 0;
}