def count_valid(passports : list[dict[str, str]], fields : list[str]) -> int:
    """Counts the passports that have the right fields"""
    return sum(
        all(field in passport for field in fields)
        for passport in passports
    )