H,W = map(int,input().split()) lsHW = [input() for i in range(H)] ans = 0 for i in range(H): ans += lsHW[i].count('W') print(ans)