//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
           int n=int.Parse(Console.ReadLine());
var a=Console.ReadLine().Split().Select(x=>int.Parse(x)).ToArray();
bool[] ok=new bool[n]
for(int i=0;i <n;i++){
ok[i]=(a[i]==i)?false:true;

}
int count=0;
for(int i=0;i <n-1;i++){
if(!ok[i]){
count++;
a[i+1]=a[i];
if(a[i+1]!=i+1){
ok[i+1]=true;
}

}

}
if(a[n-1]==n-1)
count++;
            Console.WriteLine(count);
        }
    }
}