def max_code_sreak(strs):
    slen = len(strs)
    maxs = 0
    maxForDay = 0
    for i in range(slen):
        if strs[i]== "C":
            maxs +=1
        else:
            maxs = 0
        maxForDay  = max(maxForDay, maxs)
    return maxForDay

no_of_days = input()
alldays    = ''
daysMax = 0
for i in range(no_of_days):
    curr = raw_input()
    alldays += curr
    daysMax = max(daysMax, max_code_sreak(curr))
all_max = max_code_sreak(alldays)
print daysMax, all_max