Jollo is a simple card game that children love to play. Two players compete with a standard deck of 52 cards. The 52 cards are ordered by rank and suit into a single sequence of distinct values, so any two cards can be compared and a tie can never occur.
A game is a best-of-three series: the first player to win two rounds wins the game. At the start the deck is shuffled and each player is dealt a hand of three cards. In each round both players reveal one card at the same time, and the player who shows the higher card wins that round. Revealed cards are discarded and can never be shown again.
The King's son loves this game, but he is not very clever and often loses to his little sister. Whenever he loses he cries so loudly that no one can stand it. The servant who deals the cards is afraid he will be punished if the Prince keeps losing. The servant may look at every card he deals. After dealing five cards (three to the Princess and two to the Prince), he wants to know the lowest-valued card he could deal to the Prince as a third card so that the Prince can never lose the game, no matter how poorly he plays.
In other words, find the lowest not-yet-dealt third card $Z$ for the Prince such that, however the Prince's three cards ${X, Y, Z}$ are matched against the Princess's three cards ${A, B, C}$ over the rounds, the Prince wins at least two of the three rounds.
Each test case is a single line containing five distinct integers $A$, $B$, $C$, $X$, $Y$. The first three, $A$, $B$, $C$ ($1 \le A, B, C \le 52$), are the Princess's cards, and the last two, $X$, $Y$ ($1 \le X, Y \le 52$), are the Prince's cards. The five integers on a line are all distinct.
The input contains several test cases. The last one is followed by a line of five zeros, which must not be processed.
For each test case print a single line. If, among the 47 cards not yet dealt, there is a card that guarantees the Prince cannot lose the game no matter how the rounds are played when given as his third card, print the lowest-valued such card. Otherwise print -1.