n,m=list(map(int,input().split())) print(sum([input().count("W") for i in range(n)]))