#include <stdio.h>
#include <stdlib.h>

int inf=10000000;

typedef struct{
	int *Q;
	int n;
}C_P;

int Minmin(int a,int b){
	int ans;
	if (a>b){
		ans=b;
	}
	else{
		ans=a;
	}
	return ans;
}

C_P *Change(int N,int *P){
	C_P *A=malloc(sizeof(C_P));
	int *Q=malloc(N*sizeof(int));
	int i;
	int first=0;
	for (i=0;i<N;i++){
		Q[i]=P[i];
	}
	for (i=0;i<N-1;i++){
		if (P[i]==i+1){
			if (P[i+1]==i+2){
				Q[i]=P[i+1];
				Q[i+1]=P[i];
				first++;
			}
		}
	}
	A->Q=Q;
	A->n=first;
	return A;
}

int Min(int N,int *P){
	int i,j;
	int ans=inf;
	int *Left=malloc(N*sizeof(int));
	int *Right=malloc(N*sizeof(int));
	int right_ans,left_ans;

	for (i=0;i<N;i++){
		if (P[i]==i+1){
			if (i!=0){
				for (j=0;j<i-1;j++){
					Left[j]=P[j];
				}
				Left[i-1]=P[i];
				Left[i]=P[i-1];
				for (j=i+1;j<N;j++){
					Left[j]=P[j];
				}
				left_ans=1+Min(N,Left);
			}

			if (i==0){
				left_ans=inf;
			}

			if (i!=N-1){
				for (j=0;j<i;j++){
					Right[j]=P[j];
				}
				Right[i]=P[i+1];
				Right[i+1]=P[i];
				for  (j=i+2;j<N;j++){
					Right[j]=P[j];
				}
				right_ans=1+Min(N,Right);
			}

			if (i==N-1){
				right_ans=inf;
			}
			int now_ans=Minmin(left_ans,right_ans);
			if (now_ans<ans){
				ans=now_ans;
			}
		}
	}
	if (ans==inf){
		ans=0;
	}
	return ans;
}

int main(){
	int N;
	scanf("%d",&N);
	int i;
	int *P=malloc(N*sizeof(int));
	for (i=0;i<N;i++){
		scanf("%d",&P[i]);
	}
	C_P *A=Change(N,P);
	int ans=Min(N,A->Q)+A->n;
	printf("%d\n",ans);
}