#include <bits/stdc++.h>
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vi P(N);
  for (int i = int(0); i < int(N); ++i) {
    cin >> P[i];
    P[i]--;
  }
  vb a(N, false);
  for (int i = int(0); i < int(N); ++i) {
    if (P[i] == i) a[i] = true;
  }
  if (N % 2 == 1) a.push_back(false);
  int ans = 0;
  for (int i = 0; i < a.size(); i += 2) {
    if (a[i] || a[i + 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}
