#include <bits/stdc++.h>
using namespace std;
inline int read() {
  long long s = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
  return s * f;
}
int num[100005];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) num[i] = read();
    int k = -1;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (num[i] == i) {
        if (k == -1) {
          k = i;
        } else {
          ans = ans + (i - k);
          k = -1;
        }
      }
    }
    if (k != -1) {
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
