l2=[]
s1=""
for i in range(input()):
	s=raw_input()
	s1+=s
	l=len(s)
	c=0
	l1=[]
	for j in range(0,len(s)-1):
		if(s[j]=="C" and s[j+1]=="C"):
			c+=1
		elif(s[j]=="C" and s[j+1]!="C"):
			l1.append(c+1)
			c=0
		if(j==l-2 and s[l-1]=="C"):
			l1.append(c+1)
		else:
			l1.append(0)
	l2.append(max(l1))
t=len(s1)
l3=[]
d=0
for k in range(0,len(s1)-1):
		if(s1[k]=="C" and s1[k+1]=="C"):
			d+=1
		elif(s1[k]=="C" and s1[k+1]!="C"):
			l3.append(d+1)
			d=0
		if(k==t-2 and s1[t-1]=="C"):
			l3.append(d+1)
		else:
			l3.append(0)
x=max(l3)
y=max(l2)
if(x>y):
	print y,x
else:
	print y,y