```python
def staffed_posts(wanted: list, posts: int) -> int:
    if not isinstance(posts, int) or posts <= 0:
        raise ValueError("Posts count must be a positive integer")
    
    if any(not isinstance(post, int) or post < 0 or post >= posts for post in wanted):
        raise ValueError("Invalid post number in the list of applicants")
    
    staffed = [-1] * posts
    available_posts = set(range(posts))
    
    for applicant, preferences in enumerate(wanted):
        for preference in preferences:
            if preference in available_posts:
                staffed[preference] = applicant
                available_posts.remove(preference)
                break
    
    return sum(1 for post in staffed if post != -1)
```