N,M=map(int,input().split()) print("".join([input().rstrip() for i in range(N)]).count("W"))