#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
int main() {
  auto start = high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    --v[i];
  }
  vector<int> dp(n + 1, 1 << 30);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    if (v[i] != i) {
      dp[i + 1] = min(dp[i + 1], dp[i]);
    }
    if (i + 1 < n && (v[i] == i || v[i + 1] == i + 1)) {
      dp[i + 2] = min(dp[i + 2], dp[i] + 1);
    }
    if (i + 2 < n && v[i] == i && v[i + 2] == i + 1) {
      dp[i + 3] = min(dp[i + 3], dp[i] + 2);
    }
  }
  cout << dp[n] << endl;
  cerr << "Total execution time : "
       << duration_cast<milliseconds>(high_resolution_clock::now() - start)
              .count()
       << " ms" << endl;
  return 0;
}
