m,n = map(int,input().split()) cnt = 0 strList = [input() for i in range(m)] strConcat = ''.join(strList) for i in range(len(strConcat)): if strConcat[i] == "W" : cnt += 1 print(cnt)