#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll n;
  cin >> n;
  vector<ll> p(n + 1);
  vector<ll> same(n + 1, 0);
  ll cnt = 0;
  for (ll i = 1; i < n + 1; i++) {
    cin >> p[i];
    if (i == p[i]) {
      same[i] = 1;
    }
  }
  for (ll i = 1; i < n; i++) {
    if (same[i]) {
      swap(p[i], p[i + 1]);
      cnt++;
    }
  }
  if (same[n]) {
    swap(p[n - 1], p[n]);
    cnt++;
  }
  cout << cnt << endl;
}
