a = raw_input()
a = int(a)
large = large1 = count1 = ans = ans1 = 0
for i in range(a):
    b = raw_input()
    c = list(b)
    count = 0
    for i in c:
        if i == 'C':
            count+=1
            count1+=1
        else:
            if count > large:
                ans = count
                large = count
            if count1 > large1:
                ans1 = count1
                large1 = count1
            count = 0
            count1 = 0
        if count > large:
            ans = count
            large = count
if count1 > large1:
	ans1 = count1
print ans,ans1