Problems
Farmer John is attempting to sort his
Currently, the cows are standing in a line in the order
The cows are a bit sleepy today, so at any point in time the only cow who is paying attention to Farmer John's instructions is the cow directly facing Farmer John. In one time step, he can instruct this cow to move
For example, suppose that
FJ: 4, 3, 2, 1 The only cow paying attention to FJ is cow
FJ: 3, 2, 4, 1 Now the only cow paying attention to FJ is cow
Farmer John is eager to complete the sorting, so he can go back to the farmhouse for his own breakfast. Help him find the minimum number of time steps required to sort the cows.
Input
The first line of input contains
The second line contains
Output
A single integer: the number of time steps before the
Example
4
1 2 4 3
3