N, M = input().split() List = [] for i in range(int(N)): List.append(input()) Char = "".join(List) print(Char.count("W"))