def sol(s):
	l=len(s)
	c=1 if s[0]=='C' else 0
	mx=c
	for i in range(1,l):
		if s[i]==s[i-1] and s[i]=='C':
			c+=1
		else:
			c=1 if s[i]=='C' else 0
		mx=max(mx,c)
	return mx

a=[]
for t in range(input()):
	a.append(raw_input())
mx=0
for x in a:
	mx=max(mx,sol(x))
print mx,sol(''.join(a))