n,m = map(int, input().split()) list1 = [] anser = 0 for i in range(n): a = input() b = list(a) list1.append(b) print(list1) for i in range(n): for j in range(m): if list1[i][j] == 'W': anser += 1 else: pass print(anser)