n, m = map(int, input().split()) cnt = 0 for i in range(n): S = list(input()) for s in S: if s == "W": cnt += 1 print(cnt)