def maxC(s):
	c = 0
	x = 0
	for i in s:
		if i=='C':
			c+=1
		else:
			x = max(x,c)
			c = 0
	x = max(x,c)
	return x
x = 0
y = 0
t = input()
zs = ''
for i in xrange(t):
	s = raw_input()
	zs+=s
	x = max(x,maxC(s))

y = maxC(zs)
print x,y