from itertools import groupby
final_string = ''
try:
	maximum = 0
	for _ in range(input()):
		str_in = raw_input()
		li = [[k, len(list(g))] for k, g in groupby(str_in)]
		final_string = final_string + str_in
		for x in li:
			if x[0] == 'C':
				if maximum < x[1]:
					maximum = x[1]
	maxi = 0
	#print final_string
	li = [[k, len(list(g))] for k, g in groupby(final_string)]
	for x in li:
		if x[0] == 'C':
			if maxi < x[1]:
				maxi = x[1]
	print maximum, maxi
except Exception as e:
	print str(e)