N, M = map(int, input().split()) print(sum([input().count('W') for i in range(N)]))