#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
using vch = vector<char>;
using vvch = vector<vector<char>>;
using vbo = vector<bool>;
using vvbo = vector<vector<bool>>;
using vpii = vector<pair<int, int>>;
using pqsin = priority_queue<int, vector<int>, greater<int>>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  bool tmp = false;
  int p;
  for (int i = 0; i < (int)(n); i++) {
    cin >> p;
    if (p == i + 1) {
      if (tmp) {
        ans++;
        tmp = false;
      } else
        tmp = true;
    } else if (tmp) {
      ans++;
      tmp = false;
    }
  }
  cout << ans << endl;
}
