n, m = map(int, input().split()) l = [list(map(str, input())) for _ in range(n)] x = 0 for i in l: x += i.count('W') print(x)