#include <bits/stdc++.h>
using namespace std;
inline void scd(int &a) { scanf("%d", &a); }
inline void scdd(int &a, int &b) { scanf("%d %d", &a, &b); }
inline void sctd(int &a, int &b, int &c) { scanf("%d %d %d", &a, &b, &c); }
inline void sctlld(long long int &a, long long int &b, long long int &c) {
  scanf("%I64d %I64d %I64d", &a, &b, &c);
}
inline void scdlld(long long int &a, long long int &b) {
  scanf("%I64d %I64d", &a, &b);
}
inline void sclld(long long int &a) { scanf("%I64d", &a); }
inline void scllu(unsigned long long int &a) { scanf("%I64u", &a); }
inline void scdllu(unsigned long long int &a, unsigned long long int &b) {
  scanf("%I64u %I64u", &a, &b);
}
inline void sctllu(unsigned long long int &a, unsigned long long int &b,
                   unsigned long long int &c) {
  scanf("%I64u %I64u %I64u", &a, &b, &c);
}
template <class Ver>
inline void prd(Ver a) {
  cout << a << "\n";
};
template <class Ver>
inline void prdd(Ver a, Ver b) {
  cout << a << " " << b << "\n";
};
template <class Ver>
inline void prtd(Ver a, Ver b, Ver c) {
  cout << a << " " << b << " " << c << "\n";
};
inline void debug() { printf("asd\n"); }
template <class Ver>
inline void debugd(Ver a) {
  cout << "--- " << a << endl;
};
template <class Ver>
inline void debugdd(Ver a, Ver b) {
  cout << "--- " << a << " " << b << endl;
};
template <class Ver>
inline void debugtd(Ver a, Ver b, Ver c) {
  cout << "--- " << a << " " << b << " " << c << endl;
};
void st() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
int main() {
  st();
  int ver = 0, niy = 0, hbk = 0;
  scd(ver);
  int a[ver + 5];
  for (int i = 0; i < ver; ++i) scd(a[i]);
  for (int i = 0; i < ver; ++i) {
    if (a[i] == i + 1) {
      if (a[i + 1] != i + 2 && a[i + 1] != i) {
        swap(a[i + 1], a[i]);
        ++niy;
      } else if (i > 0 && a[i - 1] != i) {
        swap(a[i - 1], a[i]);
        niy++;
      }
    } else if (a[i] != i + 1 && a[i + 1] == i + 2) {
      if (a[i] != i + 2) {
        swap(a[i], a[i + 1]);
        niy++;
      }
    }
  }
  prd(niy);
  return 0;
}
