import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(), M = sc.nextInt(), ans = 0; char A[][] = new char[N][M + 1]; for (int i = 0; i < N; ++i) { A[i] = sc.next().toCharArray(); for (int j = 0; j < M; ++j) { if (A[i][j] == 'W') ++ans; } } sc.close(); System.out.print(ans); } }