def get_analysis(lf_list):
	longest_coding  = 0
	for day in lf_list:
		day_LIST = day.split(' ')
		day_list_clean = [x for x in day_LIST if x != ' ']
		if max(day_list_clean,key=len) >longest_coding:
			longest_coding = max(day_list_clean,key=len)
	return len(longest_coding)
	
def get_analysis_total(lf_list):
	total = ''.join(lf_list)
	day_list = total.split(' ')
	day_list_clean = [x for x in day_list if x != ' ']
	return len(max(day_list_clean,key=len))
tc= raw_input()
num_tc = int(tc)

LF_hold = []

for i in range(num_tc):
	life_cycle = raw_input()
	LF_hold.append(life_cycle.replace('S',' ').replace('E',' '))
lcd = get_analysis(LF_hold)
lc = get_analysis_total(LF_hold)
print str(lcd)+' '+str(lc)