n,m=map(int,input().split()) print(sum(input().count("W") for _ in range(n)))