N,M=input().split() O=0 for i in range(int(N)):O+=input().count('W') print(O)