def a(s):
	x=y=0
	for i in s:
		if i=='E' or i=='S':
			y=0
		elif i=='C':
			y=y+1
		x=max(x,y)
	return x
b=[]
k=""
for z in range(int(raw_input())):
	s=raw_input()
	k=k+s
	b.append(a(s))
print ("%d %d"%(max(b),a(k)))