N, M = map(int, input().split())
ans = 0
for i in range(N):
    ans += input().count('W')
print(ans)