def dfs(x,y,t=0):
if x>=len(c) or y>=len(c[0]) or y<0 or x<0 or c[x][y]!='W':
return 0
#print(c)
t=1
c[x][y]='n'
t+=dfs(x+1,y)
t+=dfs(x-1,y)
t+=dfs(x,y+1)
t+=dfs(x,y-1)
return t
a,b=input().split(' ')
b=int(b)
c=[list(input()) for _ in range(b)]
#print(c)
mir=[]
mx=0
su=0
for i in range(len(c)):
for j in range(len(c[i])):
#print(c[i][j])
if c[i][j]=='W':
xx=dfs(i,j)
mir.append(xx)
mx=max(xx,mx)
su+=1
print(mx,min(mir),su)