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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
import re
n = int(raw_input())
lmax = None
prog = re.compile('(C+)')
cm = ''
while n > 0:
	s = raw_input()
	m = prog.findall(s)
	cm += s
	if m:
		lm = len(max(m))
	else:
		lm = 0
	if lmax is None:
		lmax = lm
	elif lmax < lm:
		lmax = lm
	n -= 1
cm = prog.findall(cm)
if cm:
	print lmax, len(max(cm))
else:
	print lmax, 0