n, m = map(int, input().split()) counter = 0 for i in range(n): p = input() counter += p.count('W') print(counter)