y=0

sum_uptoy=0
sum_upto=0
x=0
for _ in range(int(raw_input())):
    
    st=raw_input()
    ar=[]
    for i in range(len(st)):
        if st[i]=="C":
            sum_upto+=1
            sum_uptoy+=1
            if sum_uptoy>y:
                y=sum_uptoy
            if sum_upto>x:
                x=sum_upto
            if i==len(st)-1:
                sum_upto=0
             
                
        else:
            sum_uptoy=0
            sum_upto=0
print x,y