def fun(a):
	ans=-1
	cnt=0
	for i in a:
		if i=='C': cnt+=1
		else:
			ans=max(ans,cnt)
			cnt=0
	ans=max(ans,cnt)
	return ans
t=int(input())
z=''
a1=-1
for i in range(t):
	a=raw_input()
	a1=max(a1,fun(a))
	z+=a
a2=fun(z)
print a1,a2