Sort Machine#1144

Sort Machine

1 second
128 megabytes
Easy

There is a machine for sorting a set of different numbers. It has only one command, MOVE, with one argument. This command moves the number specified in the argument to the end of the sequence. For example, to sort the array of numbers 19, 7, 8, 25 in ascending order, two commands should be performed:

  1. MOVE 19, resulting in 7, 8, 25, 19.

  2. MOVE 25, resulting in 7, 8, 19, 25.

For a given set of numbers, find the minimum number of MOVE commands required to arrange its elements in ascending order.

Input

The first line contains the number (n \le 50). The second line contains integers in the range from to .

Output

Print the minimum number of MOVE commands required to arrange all the numbers in ascending order.

Examples

Example 1

Loading
Loading