N,M=map(int,input().split()) A = [input() for l in range(N)] cnt=0 for i in range(N): cnt+=A[i].count('W') print(cnt)