def find_longest_streak(s,slen):
	longest_streak = 0
	streak = 0
	for i in xrange(slen):
		if s[i] == 'C':
			streak += 1
		else:
			streak = 0
		longest_streak = max(streak,longest_streak)
	return longest_streak
def roys():
	month_life = ''
	N = input()
	day_streak = []
	for i in xrange(N):
		day = raw_input()
		dlen = len(day)
		day_streak.append(find_longest_streak(day,dlen))
		month_life += day
	print max(day_streak),find_longest_streak(month_life,len(month_life))
roys()