n, _ = map(int, input().split()) count = 0 for i in range(n): ss = input() count += ss.count("W") print(count)