n, m = map(int, input().split()) l = [input() for _ in range(n)] ans = 0 for i in l: ans += i.count("W") print(ans)