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