N,M = map(int,input().split()) flag = "".join([input() for x in range(N)]) target_count = flag.count("W") print(target_count)