#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;
int main() {
  int n;
  vector<int> x;
  cin >> n;
  for (int i = (int)0; i < (int)n; ++i) {
    int q;
    cin >> q;
    x.push_back(q);
  }
  int ans = 0, con = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (i == x[i] - 1 && i + 1 == x[i + 1] - 1) con++;
  }
  for (int i = (int)0; i < (int)n; ++i) {
    if (i == x[i] - 1) ans++;
  }
  cout << ans - con << endl;
  return 0;
}
