from collections import Counter N, M = map(int, input().split()) c = Counter() for _ in range(N): c.update(input()) print(c['W'])