'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def longest_streak(A):
    max_streak = 0
    count = 0
    for i in A:
        if i in "ES":
            count = 0
            continue
        else:
            count += 1
            if max_streak < count:
                max_streak = count
    return max_streak


N = int(raw_input())
B = str()
X = []
Y = 0
while N != 0:
    A = raw_input()
    X.append(longest_streak(A))
    B += A
    N -= 1
Y = longest_streak(B)
print(str(max(X)) + ' ' + str(Y))