def getlist(): return list(map(int, input().split())) N, M = getlist() ans = 0 for i in range(N): A = list(input()) ans += A.count("W") print(ans)