import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
	int p[] = new int[n];
	int i=0;
	int previous_is_met=0;
	int sum=0;
	int k=0;
        for(i=0;i<n;i++) p[i] = sc.nextInt();
        for(i=0;i<n;i++){
	    if(p[i] == (i+1)){
		if(previous_is_met == 0) previous_is_met = 1;
		k++;
            }else{
		if(previous_is_met == 1){
                    previous_is_met = 0;
                    sum=sum + k/2 + k%2;
                    k =	0;
                }
            }
        }
	sum = sum + k/2	+ k%2;
        System.out.println(sum);
    }
}
