def count_and_reduce(s, a):
    num = 0
    maxnum = 0
    for c in s:
        if c == a:
            num += 1
            maxnum = max(num, maxnum)
        else:
            num = 0
    return maxnum

t = int(raw_input())
out_d = 0
out_all = 0
s_all = ""
for n in xrange(1, t+1):
	s = raw_input()
	max_d = count_and_reduce(s, "C")
	out_d = max(max_d, out_d)
	s_all += s
out_all = count_and_reduce(s_all, "C")

print "%s %s" % (out_d,out_all)