N, M = gets.split.map(&:to_i) A = N.times.map { gets.chomp } puts A.map { |row| row.count('W') }.sum