def longest_coding_streak(N):
    count = 0
    max_streak = 0
    for i in N:
        if i=='C':
            count+=1
        else:
            max_streak = max(max_streak, count)
            count = 0
    max_streak = max(max_streak, count)
    return max_streak
    

tc=int(raw_input())
X = 0
#Y = 0
Complete_Life_Cycle = ''
while tc:
    tc=tc-1
    N = raw_input()
    Complete_Life_Cycle += N
    X = max(longest_coding_streak(N), X)
    
print X, longest_coding_streak(Complete_Life_Cycle)