n,m = map(int,input().split()) a = [] for i in range(n): v = list(input()) for j in range(m): a.append(v[j]) print(a.count('W'))