import itertools
import re
def longest(s):
	vt=0
	ptr=0
	x=len(s)
	while ptr < x:
		cur=ptr
		if s[ptr]=='C':
			lf=ptr
			while ptr < x and s[ptr]=='C':
				ptr+=1
			rg=ptr
			tmp = rg - lf
			if tmp > vt:
				vt=tmp
		else:
			ptr+=1
	return vt

d=int(raw_input())
l=[]
f=''
for i in xrange(d):
	s=raw_input()
	l.append(s)
	f+=s
ans=0
for x in l:
	tmp = longest(x)
	if tmp > ans:
		ans = tmp
print ans,longest(f)