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