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