test_cases = int(raw_input())
x = 0
y = 0
count2 = 0
while test_cases > 0:
	day = str(raw_input())
	day_streak = 0
	count = 0
	for i in day:
		if i == 'C':
			count  += 1
			count2 += 1
		else:
			if count > day_streak:
				day_streak = count
			if count2 > y:
				y = count2
			count = 0
			count2 = 0
	if count > day_streak:
		day_streak = count
	if day_streak > x:
		x = day_streak
	test_cases -= 1
if count2 > y:
	y = count2
print x,y