def count_children(graph: dict, from_node: str) -> int:
    """
    Part 2
    f([])   = 0
    f(node) = Σ_(#neigh) n_i * (1 + f(neigh_i))
    """

    if not graph[from_node]:
        return 0

    s = 0
    for (n, nxt) in graph[from_node]:
        s += n * (1 + count_children(graph, nxt))

    return s