'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'

n = int(raw_input())
allmax_c = 0

joinmax = 0
joinc = 0
for i in range(0,n):
	string = raw_input()
	num_c = 0
	max_c = 0
	for c in string:
		if c == 'C':
			num_c = num_c + 1 
			joinc = joinc + 1
		elif c != 'C':
			if num_c > max_c:
				max_c = num_c
			num_c = 0	
			if joinc > joinmax:
				joinmax = joinc
			joinc = 0	
	if num_c > max_c:
		max_c = num_c
	if max_c > allmax_c:
		allmax_c = max_c

if joinc > joinmax:
	joinmax = joinc		
print '%d %d' % (allmax_c, joinmax)