import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); int cnt = 0; for(int i = 0; i < N; i++) { String s = scan.next(); for(int j = 0; j < M; j++) { char c = s.charAt(j); if(c == 'W') { cnt ++; } } } scan.close(); System.out.println(cnt); } }