def cal(arr,n):
    big=""
    mx=0
    for i in range(0,n):
        arr[i]=arr[i].replace("S","*")
        arr[i]=arr[i].replace("E","*")
        s=arr[i].split("*")
        l=max(s, key=len)
        l=len(l)
        if l>mx :
            mx=l
        big=big+arr[i]

    return mx,len(max(big.split("*"), key=len))

def main():
    n=int(raw_input())
    ar=["" for x in range(n)]
    i=0
    m=n
    while n>0:
        ar[i]=str(raw_input())
        i=i+1
        n=n-1
    a,b=cal(ar,m)
    print a,b

main()