import re
n=int(raw_input())
r=[]
res=""
while n:
	x=raw_input()
	r.append(x)
	res=res+x
	n=n-1
ans=[]
for i in r:
	 if 'C' in i:
	 	ans.append(max(len(s) for s in re.findall(r'C+', i)))
if len(ans):
	print max(ans), max(len(s) for s in re.findall(r'C+', res))	
else:
	print "0 0"