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