def count(s):
    v=[]
    cnt=1
    for i in range(len(s)-1):  
        if s[i]=='C':
            cnt+=1
        if s[i+1]!='C':
            cnt=1
            continue
        v.append(cnt)
    if len(v)==0:
        return 0
    else:
        return max(v)

t=int(raw_input())
a=''
b=[]
for w in range(t):
    s=raw_input()
    a+=s
    m=count(s)
    b.append(m)
if len(b)==0:
    print 0,count(a)
else:
    print max(b),count(a)