:::align{center}

:::
Daisy enjoys walking in mazes to evacuate the stress of a long day of work. The
mazes that she likes are all composed of a set of rooms with one
entry room, one exit room, and in each room there are several one-way
doors leading to other rooms. Daisy's goal is to find a path from the
entry to the exit.
Daisy has a technique to solve mazes. She has noticed that the
different doors of any room have different colors and thus she can
remember her path by keeping track of the colors of doors along her
path. For that, she looks at the plan before entering the maze and
builds a deck of colored cards corresponding to the colors of doors
she needs to take. Whenever she enters a room, she goes through the
door that has the color of the topmost card in her deck and then she
discards this card.
It sometimes happens that Daisy's decks are "incomplete" and she
arrives in a room with an empty deck or with a topmost card that has a
color corresponding to none of the doors. In those cases, Daisy goes
through one of the doors in the room and, instead of discarding the
topmost card, she adds on top of her deck a card of the color of the
door she took.
Let us consider the following example maze with three rooms and three
doors: a red door from the entry to room 1, a second red door from
room 1 back to the entry, and a blue door between room 1 and the
exit. In this example maze (also depicted below) then:
- if Daisy starts with a deck containing a red card on top and a blue card below, she will go to room 1 and discard the red card, then go to the exit and discard the blue card;
- if Daisy starts with a deck containing a single red card
then she will necessarily go to room 1 as a first step, discard the
red card and from there she can choose to take the blue door and
exit (it does not matter whether her deck is empty at the end) or she
can choose to take the red door and goes back to her initial situation:
in the entry room with a single red card;
- if she starts or arrives in the entry room with an empty deck,
she will necessarily loop indefinitely.
Indeed, the entry has only one door that leads to room 1. Once
she arrives in room 1, her deck contains a red card on top
and thus she has to take the red door and discard this card,
which leads her back to the entry room with an empty deck.
:::align{center}

:::
Daisy knows that, in all of her labyrinths, she can always go from the
entry room to the exit room with the right deck. However, some decks
do not allow her to escape, whatever the choices she may ever do.
She wonders: what is the
minimal size of a deck that allows her to escape? Daisy gives you the
plan of the maze and asks you to help her determine the minimal size
of a deck that allows her go from the entry room to the exit if she
makes the right choices.