#include <bits/stdc++.h>
int main() {
  size_t n;
  std::cin >> n;
  std::vector<size_t> p(n);
  for (auto&& e : p) {
    std::cin >> e;
  }
  std::vector<size_t> v;
  for (size_t i = 0; i < n; i++) {
    if (i + 1 == p.at(i)) {
      v.emplace_back(i);
    }
  }
  if (v.size() == 0) {
    std::cout << 0 << std::endl;
    return 0;
  }
  size_t ans = 0;
  for (size_t i = 0; i < v.size() - 1; i += 2) {
    ans += std::max(v.at(i + 1), v.at(i)) - std::min(v.at(i + 1), v.at(i));
  }
  if (v.size() % 2 == 0) {
    std::cout << ans << std::endl;
  } else {
    std::cout << ans + 1 << std::endl;
  }
  return 0;
}
