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