N, M = map(int, input().split()) A = [input() for _ in range(N)] cnt = 0 for i in range(N): for j in range(M): if A[i][j]=="W": cnt+=1 print(cnt)