h,w=map(int,input().split()) print(sum([input().count('W') for _ in range(h)]))