x,y=map(int,input().split())
M=[input() for i in range(x)]
ans=0
for i in range(x):
  for j in range(y):
    if M[i][j]=="W":
      ans+=1
print(ans)