N,M = map(int,input().split())
src = [input() for i in range(N)]
ans = sum(map(lambda row:row.count('W'),src))
print(ans)