class Problem0712: def solve(this): n,m = map(int, input().split()) res = 0 for i in range(n): res += len([c for c in input() if c == "W"]) print(res) if __name__ == "__main__": problem = Problem0712() problem.solve()