#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 = 1e8;
signed main() {
  long long int N;
  cin >> N;
  vector<long long int> p(N), v(N, 0);
  for (long long int i = 0; i < (long long int)(N); i++) {
    cin >> p[i];
    if (i + 1 == p[i]) v[i]++;
  }
  long long int len = INF;
  long long int cnt = 0;
  for (long long int i = 0; i < (long long int)(N); i++) {
    if (len == INF && v[i] == 1)
      len = 0;
    else if (len != INF && v[i] == 0)
      len++;
    else if (len != INF && v[i] == 1) {
      if (len == 0)
        cnt++;
      else
        cnt += 2;
      len = INF;
    }
  }
  if (len == 0) cnt++;
  cout << cnt;
}
