from itertools import groupby
t=int(raw_input())
s=""
l=[]
while t>0:
    l.append(raw_input())
    t=t-1
l1=[]
for i in range(len(l)):
    strs = l[i]
    l2=list()
    l2=[[k,len(list(g))] for k, g in groupby(strs)]
   
    largest=0
    for j in range(len(l2)):       
        if(l2[j][0] == 'C' and l2[j][1]>largest):
            largest=l2[j][1]
    l1.append(largest)
maxim=max(l1)
maxim=str(maxim)
str1=""
for i in range(len(l)):
    str1=str1+l[i]
l3=list()
l3=[[k,len(list(g))] for k, g in groupby(str1)]    
largst=0
for i in range(len(l3)):
    if(l3[i][0] == 'C' and l3[i][1]>largst):
        largst=l3[i][1]
largst=str(largst)        
print(maxim+" "+largst)