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