r,c = gets.chomp.split(" ").map{ |i| i.to_i - 1} count = 0 0.step(r) do |i| chars = gets.chomp.chars 0.step(c) do |j| count += 1 if chars[j] == "W" end end puts count