n = input()
maximum = []

res = []

for i in xrange(0, n):
    values = raw_input()
    count = 0
    max_count = 0
    res.append(values)
    for j in xrange(0, len(values)):
        if values[j] == 'C' :
            x=values[j]
            count += 1
            if j == len(values) - 1:
                if count>max_count:
                    max_count=count
        elif values[j]!='C' :
            if count > max_count:
                max_count = count
            count = 0
    maximum.append(max_count)


print  max(maximum),

result = "".join(res)
max_count = 0
count = 0
for j in xrange(0, len(result)):
    if result[j] == 'C' :
        count += 1
        if j == len(result) - 1:
            if count > max_count:
                max_count = count
    else:
        if count > max_count:
            max_count = count
        count = 0

print max_count