#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 18;
const long long MAX = 100005;
const long long MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
istream &operator>>(istream &i, vector<T> &v) {
  for (long long j = (0); j < (v.size()); j++) i >> v[j];
  return i;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "	";
  }
  return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  long long n;
  cin >> n;
  vector<long long> a(n);
  cin >> a;
  vector<long long> b(n);
  for (long long i = (0); i < (n); i++) {
    if (i + 1 == a[i]) {
      b[i] = 1;
    }
  }
  vector<long long> s(n + 2);
  for (long long i = (0); i < (n); i++) {
    if (b[i] == 0) continue;
    s[i + 1] = s[i] + b[i];
  }
  long long ans = 0;
  for (long long i = (0); i < (n + 1); i++) {
    if (s[i + 1] == 0) {
      if (s[i] > 1) {
        ans += s[i] - 1;
      } else {
        ans += s[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
