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