n,m=map(int,input().split()) s=0 for i in range(0, n): s += input().count('W') print(s)