# Read input from stdin and provide input before running code
import re
n =int(raw_input())
'''max=0
str=''
'''
maxx=0
strr=''
while(n):
	n=n-1
	s=raw_input()
	strr=strr+s
	l=re.findall('C+',s)
	if(len(l)!=0):
		temp=len(max(l))
		if(temp>maxx):
			maxx=temp
l=re.findall('C+',strr)
temp=0
if(len(l)!=0):
	temp=len(max(l))
j=str(maxx)+' '+str(temp)	
print j


#print 'Hello World!'