#include <bits/stdc++.h>
using namespace std;
const int MD = (int)1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2>
void dbg(const T& fst, const T2&... rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> ck(100100, 0);
  for (int(i) = 0; (i) < (n); (i)++) {
    int p;
    cin >> p;
    if (i == p - 1) ck[p - 1] = 1;
  }
  int ans = 0;
  for (int(i) = 0; (i) < (100010); (i)++) {
    if (ck[i] == 1 && ck[i + 1] == 1) {
      ans++;
      ck[i] = ck[i + 1] = 0;
    }
  }
  for (int(i) = 0; (i) < (100010); (i)++) {
    if (ck[i] == 1) ans++;
  }
  cout << ans << "\n";
  return 0;
}
