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