#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18 + 1;
const ll DIV = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long N;
  cin >> N;
  vector<ll> p(N);
  ll count = 0;
  ll next = 0;
  for (size_t i = 0; i < N; i++) {
    cin >> p[i];
    if (p[i] == i + 1) count++;
    if (i > 0 && p[i] == i + 1 && p[i - 1] == i) next++;
  }
  cerr << count << ":" << next << endl;
  cout << count - next << endl;
  return 0;
}
