allstring=[]
maxlen=[]
alldaylength=[]

def length(string):
    l=0
    temp=0
    daylength=max(temp,l)
    for i in range(len(string)):
        if string[i]=='C':
            l+=1
        else:
            daylength=max(temp,l)
            temp=daylength
            l=0
    return max(daylength,l)
for _ in range(input()):
    string=raw_input()
    daymax=length(string)
    alldaylength.append(daymax)
    allstring.append(string)



astring=''.join(allstring)
universalmax=length(astring)
print max(alldaylength),
print universalmax