#include <bits/stdc++.h>
using namespace std;
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          dy8[8] = {1, 1, 0, -1, -1, -1, 0, 1},
          dx9[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1},
          dy9[9] = {1, 1, 0, -1, 0, -1, -1, 0, 1}, dx4[4] = {0, 1, 0, -1},
          dy4[4] = {1, 0, -1, 0};
template <class T>
inline bool maxi(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool mini(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long n, in, ans = 0;
  cin >> n;
  bool f = 0;
  for (int i = (0), i_len = (n); i < i_len; ++i) {
    cin >> in;
    if (in == i + 1) f = !f;
    if (f) ++ans;
  }
  cout << ans << "\n";
  1;
}
