#include <bits/stdc++.h>
using namespace std;
constexpr double PI = 3.1415926535897932;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int cnt = 0;
  bool flag = false;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    if (p == i + 1) {
      if (!flag) flag = true;
      ++cnt;
    } else {
      flag = false;
      if (cnt > 0) {
        ans += (cnt == 1) ? cnt : cnt - 1;
        cnt = 0;
      }
    }
  }
  if (cnt > 0) ans += (cnt == 1) ? cnt : cnt - 1;
  cout << ans << endl;
}
