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