using System; using System.Linq; using System.Collections; using System.Collections.Generic; public class P{ public static void Main(){ int n = InputToInt(); int[] m = Input().Split().MapInt(); int c = n; int ans = 0; for(int i=n; i>0; --i){ if(m[i-1] == c){ ++ans; --c; } } Print(n-ans); } public static void Print(params object[] o){ for(int i=0; i