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