def main(): N, M = map(int, input().split()) ctr = 0 for _ in range(N): ctr += input().count("W") print(ctr) if __name__ == "__main__": main()