'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import re
n = int(raw_input())
max_each = []
max_all = []
for kappa in range(n):
    text = raw_input()
    max_all.append(text)
string = ''
for foo in max_all:
    string  = string + foo
setst = set(string)
if 'C' not in setst:
    print '0 0'
else:
    for i in max_all:
        l = re.findall('CC{0,}', i)
        numc = map(lambda x:x.count('C'), l)
        max_each.append(max(numc))
    code_each = max(max_each)
    l1 = re.findall('CC{0,}', string)
    l12 = map(lambda y:y.count('C'), l1)
    code_all = max(l12)
    print '%s %s' %(code_each, code_all)