process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
var sub_fn = (ary)=>{
  
}
reader.on('close', () => {
  var x = lines[0].split(' ')[0]
  var y = lines[1].split(' ')
  //console.log(y)
    var cnt = 0;

  for(var i in y){
    if(y[i] >= i){
    ++cnt}
  }
  console.log(cnt)
  
 // var cnt = [];


  
});
