#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    t--;
    if (t == i)
      cnt++;
    else if (cnt == 1)
      ans++, cnt = 0;
    else if (cnt > 1)
      ans += cnt - 1, cnt = 0;
  }
  if (cnt == 1)
    ans++;
  else if (cnt > 1)
    ans += cnt - 1;
  cout << ans << endl;
}
