a,b = map(int,input().split()) c = 0 for i in range(a): d = list(input()) c += d.count("W") print(c)