Heonwoo's class went on a school trip to Jeju Island. A teaching assistant in sunglasses was waiting outside the airport.
"Anyone who is not standing in order of student number had better be ready to get hit."
The assistant picks some of the students in the line and hits them. Once the students who were hit step out of the line, the numbers of the remaining students must increase from front to back. The assistant hits as few students as possible.
Given the number of students N and their numbers in the order they currently stand, find how many students get hit.