from pprint import pprint def main(): n,m=map(int,input().split()) a=[] for i in range(n): a.append(input()) cnt=0 for i in range(len(a)): for j in range(len(a[i])): if a[i][j]=="W": cnt+=1 print(cnt) if __name__ == "__main__": main()