题目描述
Give you a permutation of 8 numbers(every number is between 1 and 8, and all the numbers are distinct); You are asked to find minimum steps to change the sequence to the ascending order by only allowed to reversed first k(1 <= k <= 8) numbers(cost one step);
输入
One string as describe above(no space between the numbers).
输出
Output the minimum steps to get the ascending order.
提示
For the second sample:
56781234 -> 87651234 (the first step) -> 43215678 (the second step) -> 12345678 (the third step)