def longest_streak(string):
	ls = 0
	s = 0
	for i in range(len(string)):
		if string[i] == 'C':
			s += 1
		else:
			s = 0
		ls = max(s, ls)
	return ls

ml = ''

N = int(raw_input())
ds = []

for i in range(N):
	x = raw_input()
	ds.append(longest_streak(x))
	ml += x

print max(ds), longest_streak(ml)