a,b = map(int,input().split()) array = [input() for i in range(a)] port = "".join(array) print(port.count("W"))