N = int(raw_input())
final = ""
grt = 0
for i in range(0,N):
	
	raw = raw_input()

	count = 1
	
	for i in range(1,len(raw)):
		if(raw[i] == "C" and raw[i] == raw[i-1]):
			count+=1
			if count > grt:
				grt = count
		else:
			count = 1
	
	final = final + raw	
count = 1
h = 0
#print final
#print grt
for i in range(1,len(final)):
	if(final[i] == "C" and final[i] == final[i-1]):
		count +=1
		if count > h:
			h = count
	else:
		count = 1

print grt,h