```python
def shelf_fit(widths: list, shelf: int) -> int:
    if not isinstance(widths, list) or not all(isinstance(w, int) and w > 0 for w in widths):
        raise ValueError("widths must be a list of positive integers")
    if not isinstance(shelf, int) or shelf < 0:
        raise ValueError("shelf must be a non-negative integer")

    total_width = 0
    for width in widths:
        if total_width + width <= shelf:
            total_width += width
        else:
            break

    return len(widths) - total_width
```