#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;
}
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> a;
  for (long long i = 0; i < (long long)(n); ++i) {
    cin >> p[i];
    if (p[i] == i + 1) {
      a.push_back(i + 1);
    }
  }
  if (a.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < (int)a.size(); i += 2) {
    if (i != (int)a.size() - 1) ans += a[i + 1] - a[i];
  }
  if (a.size() % 2) {
    cout << ans + 1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
