#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
bool compare_by_b(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b) {
  return b != 0 ? euclidean_gcd(b, a % b) : a;
}
void solve(long long N, std::vector<long long> p) {
  bool flag = false;
  int ans = 0;
  int cnt = 0;
  for (int i = (0); i < (N); ++i) {
    if (p[i] == i + 1) {
      flag = true;
      cnt++;
    } else {
      flag = false;
      if (cnt == 2)
        ans++;
      else
        ans += cnt;
      cnt = 0;
    }
  }
  flag = false;
  if (cnt == 2)
    ans++;
  else
    ans += cnt;
  cnt = 0;
  cout << ans << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &p[i]);
  }
  solve(N, std::move(p));
  return 0;
}
