N, M = map(int, input().split()) A = [input() for _ in range(N)] ans = 0 for x in A: ans += x.count("W") print(ans)