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