n,m = map(int, input().split()) c = 0 for i in range(n): c += input().count('W') print(c)