N, M = map(int, input().split()) ans = 0 for i in range(N): s = input() for j in range(M): if s[j] == 'W': ans += 1 print(ans)