n, _ = map(int, input().split()) print(sum([input().count("W") for _ in [0] * n]))