r,c=map(int,input().split()) ls=[] cnt=0 for i in range(r): ls.append(input()) for i in range(r): cnt=cnt+ls[i].count("W") print(cnt)