m,n = map(int,input().split()) strList = [input() for i in range(m)] strConcat = ''.join(strList) print(strConcat.count("W"))