#include <bits/stdc++.h>
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> p(n), memo;
  for (int i = (int)0; i < (int)n; ++i) cin >> p[i];
  for (int i = (int)0; i < (int)n; ++i) {
    if (p[i] == i + 1) {
      memo.push_back(i);
    }
  }
  int ans = 0;
  if (memo.size() == 0) {
    cout << 0 << "\n";
    return;
  }
  for (int i = 0; i < memo.size() - (int)memo.size() % 2; i += 2) {
    if (memo.size() % 2) ++ans;
    ans += memo[i + 1] - memo[i];
  }
  cout << ans << "\n";
  return;
}
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solve();
  return 0;
}
