n, m = map(int, input().split()) num = 0 for i in range(n): s = input() for j in range(m): if s[j] == "W": num += 1 print(num)