#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int P = 1000000007;
const int INF = INT_MAX;
const long long int LLINF = 1LL << 60;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < (n); ++i) cin >> v[i];
  int num;
  long long int ans = 0;
  vector<char> s(n);
  for (int i = 0; i < n; i++) {
    if (v[i] == i + 1)
      s[i] = 'x';
    else
      s[i] = 'o';
  }
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'x' || s[i + 1] == 'x') {
      s[i] = 'o';
      s[i + 1] = 'o';
      ans++;
    }
  }
  cout << (ans) << endl;
  return 0;
}
