n, m = map(int, input().split()) ans = 0 for j in range(n): aj = input() W_in_aj = [i for i in aj if i == "W"] ans += len(W_in_aj) print(ans)