During a break, Hayoon wants to divide a permutation into several Lego blocks.
A permutation of length is a sequence in which every integer from to appears exactly once. Every block must contain at least one consecutive element of the original permutation, and the blocks keep their original left-to-right order.
The division must satisfy all of the following conditions.
- Every element belongs to exactly one block.
- Elements in the same block occupy consecutive positions in the original permutation.
- After sorting the elements inside every block in ascending order and concatenating the blocks from left to right, the resulting sequence is .
For example, if , it can be divided into the three blocks , , and .
Find the maximum possible number of blocks satisfying all conditions.
Input
The input is given in the following format.
Output
Print the maximum possible number of blocks satisfying all conditions.
Constraints
- .
- ().
- ().
Subtasks
Samples
Dividing the permutation into , , and satisfies all conditions. No division into four or more blocks is possible, so the answer is .
There is no valid division into two or more blocks, so the whole permutation must be one block.