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