import re
def check(stra):
    maxc=0;
    a=re.findall(r'\CC*',stra)
    for i in range(len(a)):
        if(len(a[i])>maxc):
            maxc=len(a[i])
    return maxc

case=int(raw_input())
maxn=0
temp2=""
for i in range(case):
    temp=raw_input()
    temp2=temp2+temp
    temp1=check(temp)
    if temp1>maxn:
        maxn=temp1
    
print str(maxn)+" "+str(check(temp2))
#print check(temp2)