S=input().split(' ') N=int(S[0]) M=int(S[1]) count=0 #i for i in range(N): A=input() for j in range(M): if(A[j]=='W'): count=count + 1 else: count=count print(count)