<?php
  $n = trim(fgets(STDIN));
  $p = explode(" ", trim(fgets(STDIN)));
  $cnt = 0;
  $ans = 0;
  for($i=0; $i<$n; $i++){
      if($p[$i]-1 == $i){
          $cnt++;
      }else{
          if($cnt > 1){
              $cnt--;
              $ans += $cnt;
          } else {
              $ans += $cnt;
          }
          $cnt=0;
      }
      if($i == $n-1){
          if($cnt > 1){
              $cnt--;
              $ans += $cnt;
          } else {
              $ans += $cnt;
          }
      }
  }
  echo $ans;