var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var [nm,arr]= input.trim().split("\n");
arr=arr.split(" ").map(Number);
var cnt = 0;
for(var i=0;i<=1000;i++){
   if(arr.length==0)break;
   if(arr[0] != i+1) {
      arr.pop();
      cnt++;
   }else {
      arr.shift();
   }
}
console.log(cnt);
