N, M = (int(i) for i in input().split()) A = list(input() for i in range(N)) ans = 0 for s in A: ans += s.count('W') print(ans)