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