n,m = map(int,input().split()) res = 0 for i in range(n): for c in input(): res += (c == 'W') print(res)