using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main() { var NM = ReadLine().Split().Select(int.Parse).ToArray(); var a = 0; for (int i = 0; i < NM[0]; i++) { a += ReadLine().Count(x => x == 'W'); } WriteLine(a); } }