def single(s):
    i,clist=0,[]
    counter=0
    while i<len(s):
        if s[i]=='C':
            counter+=1
            i+=1
        else:
            clist.append(counter)    
            counter=0
            i+=1
    clist.append(counter)
    return max(clist)           
                
##def max_seq(s1,s2):
##    counter,count=0,0
##    for i in range(1,len(s1)):
##        if s1[-i]=='C':
##            counter+=1
##        else:
##            break
##    for i in range(len(s2)):
##        if s2[i]=='C':
##            count+=1
##        else:
##            break
##    return counter+count
    
        
n=int(raw_input())
slist,stringlist,newlist=[],[],[]
while n>0:
    s=raw_input().upper()
    stringlist.append(s)
    slist.append(single(s))
    n-=1
newlist=''.join(stringlist)

k=max(slist)
a=single(newlist)
if k>a:
    a=k
print k,a