n, _ = map(int, input().split()) s = "" for _ in range(n): s += input() print(s.count("W"))