#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9 + 7;
const int INF = 1e9;
const lint LINF = 1e18;
using flt = double;
const flt E = exp(1.0);
const flt PI = acos(-1.0);
template <lint mod>
class ModInteger {
 public:
  lint val;
  ModInteger() : val(0) {}
  ModInteger(lint ival) : val(ival >= 0 ? ival % mod : mod - (-ival) % mod) {}
  bool operator!() { return val == 0; }
  bool operator<(ModInteger that) { return val < that.val; }
  bool operator>(ModInteger that) { return val > that.val; }
  bool operator<=(ModInteger that) { return val <= that.val; }
  bool operator>=(ModInteger that) { return val >= that.val; }
  bool operator==(ModInteger that) { return val == that.val; }
  bool operator!=(ModInteger that) { return val != that.val; }
  ModInteger operator++() {
    val++;
    return *this;
  }
  ModInteger operator--() {
    val--;
    return *this;
  }
  ModInteger& operator+=(ModInteger that) {
    val = (val + that.val) % mod;
    return *this;
  }
  ModInteger& operator-=(ModInteger that) {
    val = ((val - that.val) % mod + mod) % mod;
    return *this;
  }
  ModInteger& operator*=(ModInteger that) {
    val = (val * that.val) % mod;
    return *this;
  }
  ModInteger& operator/=(ModInteger that) {
    lint inv = that.val, rem = 1, power = mod - 2;
    while (power > 1) {
      if (power % 2) rem = (rem * inv) % mod;
      inv = (inv * inv) % mod;
      power /= 2;
    }
    inv = (rem * inv) % mod;
    val = (val * inv) % mod;
    return *this;
  }
  ModInteger operator+(ModInteger that) { return ModInteger(*this) += that; }
  ModInteger operator-(ModInteger that) { return ModInteger(*this) -= that; }
  ModInteger operator*(ModInteger that) { return ModInteger(*this) *= that; }
  ModInteger operator/(ModInteger that) { return ModInteger(*this) /= that; }
  ModInteger& operator%=(ModInteger that) {
    val = val % that.val;
    return *this;
  }
  ModInteger operator%(ModInteger that) { return ModInteger(*this) %= that; }
};
using mint = ModInteger<MOD>;
istream& operator>>(istream& is, mint& n) { return is >> n.val; }
ostream& operator<<(ostream& os, mint n) { return os << n.val; }
template <typename Tp>
Tp gcd(Tp m, Tp n) {
  if (!m || !n) {
    cout << "GCD error: zero inputed" << endl;
    return 0;
  } else if (!(m % n))
    return n;
  else
    return gcd(n, m % n);
}
template <typename Tp>
Tp lcm(Tp m, Tp n) {
  if (!m || !n) {
    cout << "LCM error: zero inputed" << endl;
    return 0;
  } else
    return m * n / gcd(m, n);
}
template <typename Tp1, typename Tp2>
Tp1 ipow(Tp1 a, Tp2 p) {
  if (p < 0) {
    cout << "Power error: a minus number inputed" << endl;
    return 0;
  } else if (!p)
    return 1;
  Tp1 res = a, rem = 1;
  while (p > 1) {
    if (p % 2) rem *= res;
    res *= res;
    p /= 2;
  }
  return rem * res;
}
template <typename Tp>
Tp fact(Tp n) {
  if (n < 0) {
    cout << "Factorial error: a minus number inputed" << endl;
    return 0;
  } else if (!n)
    return 1;
  else if (n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
template <typename Tp>
void pfact(Tp n, map<Tp, int>& res) {
  if (n <= 1) {
    cout << "Prime factorization error: cannot factorize an integer less than 2"
         << endl;
    return;
  }
  if (res.size())
    cout << "Prime factorization warning: the map already contains some numbers"
         << endl;
  Tp pos = 2, pmax = n;
  while (pos * pos <= pmax) {
    if (!(n % pos)) {
      res[pos]++;
      n /= pos;
    } else
      pos++;
  }
  if (n != 1) res[n]++;
  return;
}
template <typename Tp>
Tp comb(Tp n, Tp r) {
  if (n < 0 || r < 0) {
    cout << "Combination error: a minus number inputed" << endl;
    return 0;
  } else {
    lint res = 1;
    for (int i = 0; i < r; i++) res *= (n - i) / (i + 1);
    return res;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0, temp = 0;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    p--;
    if (i == p) {
      temp++;
      flag = true;
    } else if (flag && i != p) {
      ans += max(1, temp - 1);
      flag = false;
      temp = 0;
    }
  }
  if (flag) ans += max(1, temp - 1);
  cout << ans << endl;
  return 0;
}
