```python
"""Count the hits a key stream scores on a direct-mapped cache."""


def slot_hits(keys: list, slots: int) -> int:
    # TODO: reject a bad slot count and non-integer keys, then replay
    # the stream against the slot table, counting hits and evicting
    # on every miss.
    if not isinstance(slots, int) or slots <= 0:
        raise ValueError("Invalid slot count")
    if not all(isinstance(key, int) for key in keys):
        raise ValueError("Invalid key")
    held = [None] * slots
    hits = 0
    for key in keys:
        slot = key % slots
        if held[slot] is not None and held[slot] != key:
            held[slot] = key
            hits += 1
        else:
            held[slot] = key
    return hits
```