n, m = map(int, input().split()) white_flag = 0 for i in range(n): white_flag += input().count("W") print(white_flag)