#include <bits/stdc++.h>
using namespace std;
long long INF = 1E9;
long long M = 1E9 + 7;
inline long long max_(long long a, long long b) { return (a > b) ? a : b; }
inline long long min_(long long a, long long b) { return (a < b) ? a : b; }
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (T x : p) os << x << " ";
  os << "]" << endl;
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "{ ";
  for (T x : p) os << x << " ";
  os << "}" << endl;
  return os;
}
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const map<Tk, Tv>& p) {
  os << "{ ";
  for (pair<Tk, Tv> x : p) os << x << " ";
  os << "}" << endl;
  return os;
}
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const pair<Tk, Tv>& p) {
  os << "{" << p.first << ',' << p.second << "}";
  return os;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("inp.txt", "r")) {
    freopen("inp.txt", "r", stdin);
    freopen("outp.txt", "w", stdout);
  }
  long long n;
  cin >> n;
  long long a[n + 1], i;
  for (i = 1; i <= n; i++) cin >> a[i];
  long long l = 1, h = 1, ans = 0;
  while (h <= n) {
    if (a[h] == h) {
      h++;
    } else {
      if (l != h) {
        long long curr = (h - l);
        ans += (curr == 1) ? 1 : (curr - 1);
      }
      h++;
      l = h;
    }
  }
  if (l != h) {
    long long curr = (h - l);
    ans += (curr == 1) ? 1 : (curr - 1);
  }
  cout << ans;
  return 0;
}
