H,W = map(int,input().split()) ans = 0 for y in range(H): ans = ans + input().count('W') print(ans)