N,M = map(int,input().split()) print(sum(a.count('W') for a in [input() for _ in range(N)]))