n, m = map(int, input().split()) s = [input() for _ in range(n)] x = 0 for i in s: x += i.count('W') print(x)