import java.util.*; public class Exercise38{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int num = sc.nextInt(); ArrayList array = new ArrayList(); for (int n = 0; n < num; n++){ array.add(sc.nextInt()); } int count = 0; for (int n = 1; n < array.size(); n++){ if (array.get(n - 1) > array.get(n)){ count++; int x = array.get(n); array.remove(n); array.add(0, x); } } System.out.println(count); } }