n,m=map(int,input().split()) d='' for _ in range(n): a=input() d=d+a print(d.count('W'))