#include <bits/stdc++.h>
const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < (int)vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  }
  return os;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  vector<int> flag(N);
  for (int i = 0; i < N; i++) flag[i] = (p[i] == i + 1);
  flag.emplace_back(0);
  int ans = 0, cnt = 0;
  for (int i = 0; i <= N; i++) {
    if (flag[i])
      cnt++;
    else {
      if (cnt) ans += max(1, cnt / 2);
      cnt = 0;
    }
  }
  cout << ans << "\n";
  return 0;
}
