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