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