n,m=map(int,input().split()) a=[input() for i in range(n)] c=0 for i in range(0,n): s=a[i] T=[c for c in s] c+=s.count("W") print(c)