import sys readline=sys.stdin.readline N,M=map(int,readline().split()) ans=0 for _ in range(N): ans+=readline().rstrip().count("W") print(ans)