def METHOD_NAME(
    events: List[int], count_predicate: Callable, keep_predicate: Callable
) -> int:
    """
    This function count the number of events matching a predicate and filters the events list inplace following another.
    It returns the count of matching events.
    """
    total_count = 0
    filtered_events = []
    for event in events:
        if count_predicate(event):
            total_count += 1
        if keep_predicate(event):
            filtered_events.append(event)
    events[:] = filtered_events
    return total_count