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