#include #define rep(i, n) for(long long i = 0; i < n; i ++) using namespace std; int main(){ int n, m; cin >> n >> m; vector a(n); rep(i, n) cin >> a[i]; int count = 0; rep(i, n){ rep(j, m){ if(a[i][j] == 'W') count ++; } } cout << count << endl; return 0; }