#include <bits/stdc++.h>
int main() {
  int n;
  int ans = 0;
  std::vector<int> aList;
  std::vector<bool> isSame;
  std::cin >> n;
  aList.resize(n);
  isSame.resize(n, false);
  for (int i = 0; i < n; i++) std::cin >> aList[i];
  for (int i = 0; i < n; i++)
    if (i + 1 == aList[i]) isSame[i] = true;
  for (int i = 0; i < n - 1; i++) {
    if (i == n - 2 && (isSame[i] || isSame[i + 1])) {
      ans++;
      break;
    }
    if (isSame[i] && !isSame[i + 1]) ans++;
    if (isSame[i] && isSame[i + 1]) ans++, i++;
  }
  std::cout << ans << std::endl;
  return 0;
}
