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