#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>p(N+2);
  for(int i=1;i<=N;i++)
    cin>>p.at(i);
  p.at(0)=-1; p.at(N+1)=-1;
  int sum=0;
  for(int i=1;i<=N+1;i++){
  if(p.at(i)==i)
    sum++;
    else{
     A.push_back(sum); sum=0;
    }
    }int ans=0;
  for(auto x:p){
  ans+=(1+sum)/2;
  }cout<<ans<<endl;
    return 0;
}