#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 2e4 + 5, inf = 0x3f3f3f3f, mod = 1e9 + 7;
int n, a[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (i == n) {
      if (a[i] == i) ans++;
    } else {
      int s1 = 0, s2 = 0;
      if (a[i] == i)
        s1++;
      else
        s2++;
      if (a[i + 1] == i + 1)
        s1++;
      else
        s2++;
      if (s2 == 2)
        continue;
      else
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
