#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;
signed main() {
  long long int N;
  cin >> N;
  vector<long long int> p(N);
  for (long long int i = 0; i < (long long int)(N); i++) cin >> p[i];
  long long int cnt = 0;
  for (long long int i = 0; i < (long long int)(N); i++)
    if (p[i] == i + 1) cnt++;
  long long int num = 0;
  for (long long int i = 0; i < (long long int)(N - 1); i++)
    if (p[i] == i + 1 && p[i + 1] == i + 2) num++;
  long long int ans = cnt - num;
  cout << ans;
}
