Woburn Challenge 2016-17 Round 3 - Junior Division

Pokémarts are stores which are always stocked with useful items to help Pokémon trainers on their journeys. However, keeping Pokémarts sufficiently stocked is at least as difficult as catching Pokémon!
You've been placed in charge of planning out an upcoming shipment of
Unfortunately, items are only allowed to be moved in a particular
fashion. The only type of operation which may be performed consists of
taking a single item from the top of one warehouse's stack, and moving
it to the top of another warehouse's stack. Items may never be moved
away from warehouse
Of course, constructing entire warehouses is expensive, so you'd like to avoid doing so. As such, you'd like to determine the minimum number of intermediate warehouses which must be constructed, such that the shipment may then be completed successfully.
Input Specification
The first line of input consists of a single integer
Output Specification
Output one line consisting of a single integer – the minimum number of intermediate warehouses required to complete the shipment.
Sample Input
3
3
1
2
Sample Output
1
Sample Explanation
With one intermediate warehouse
- Move item
from warehouse to . - Move item
from warehouse to . - Move item
from warehouse to . - Move item
from warehouse to .
Comments