#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 100000000000000000;
double PI = 3.1415926535;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
long long dp[2010][2010];
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int case1 = 0, case2 = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      if (A[i] == i + 1 && A[i + 1] == i + 2) {
        case1++;
      } else if (i > 0 && A[i] == i + 1 && A[i - 1] != i) {
        case2++;
      } else if (A[i] == i + 1) {
        case2++;
      }
    } else {
      if (A[i] == i + 1) case2++;
    }
  }
  cout << case1 + case2 << endl;
}
