N, M = map(int, input().split()) S = "" for i in range(N): S += input() ans = S.count("W") print(ans)