a, b = map(int,input().split()) cnt = 0 lines = [input() for i in range(a)] for line in lines: for dot in line: cnt += 1 if dot == 'W' else 0 print(cnt)