from typing import Dict
from typing import Any


def _count_populations_in_params(params: Dict[str, Any], prefix: str) -> int:
    """
    Counts the number of electron or ion populations in a ``params`` `dict`.

    The number of populations is determined by counting the number of items in
    the ``params`` `dict` with a key that starts with the string defined by
    ``prefix``.
    """
    return len([key for key in params if key.startswith(prefix)])