------
## 最终结论
```python
def numEnclaves(A):
    if not A:
        return 0

    rows, cols = len(A), len(A[0])

    def dfs(r, c):
        if r < 0 or r >= rows or c < 0 or c >= cols or A[r][c] == 0:
            return
        A[r][c] = 0
        dfs(r + 1, c)
        dfs(r - 1, c)
        dfs(r, c + 1)
        dfs(r, c - 1)

    # Remove land connected to the left and right boundaries
    for i in range(rows):
        if A[i][0] == 1:
            dfs(i, 0)
        if A[i][cols - 1] == 1:
            dfs(i, cols - 1)

    # Remove land connected to the top and bottom boundaries
    for j in range(cols):
        if A[0][j] == 1:
            dfs(0, j)
        if A[rows - 1][j] == 1:
            dfs(rows - 1, j)

    # Count remaining land cells
    return sum(A[i][j] == 1 for i in range(rows) for j in range(cols))

# Example usage
print(numEnclaves([[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]])) # Output: 3
print(numEnclaves([[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]])) # Output: 0
```