ANS=0 N,M=map(int,input().split()) for i in range(N): S=input() ANS+=S.count("W") print(ANS)