#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int mod1 = 998244353;
vector<long long int> g[100000 + 5];
bool vis[100000 + 5];
long long int d, x, y;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void ex(long long int A, long long int B) {
  if (B == 0) {
    d = A;
    x = 1;
    y = 0;
  } else {
    ex(B, A % B);
    long long int temp = x;
    x = y;
    y = temp - (A / B) * y;
  }
}
void dfs(long long int u) {
  vis[u] = 1;
  for (long long int i = 0; i < g[u].size(); i++) {
    long long int v = g[u][i];
    if (vis[v] != 1) dfs(v);
  }
}
long long int power(long long int a, long long int b) {
  if (b == 1) return a;
  if (a > mod) a %= mod;
  long long int r = 1;
  while (b) {
    if (b & 1) r = r % mod * a % mod;
    a = a % mod * a % mod;
    b /= 2;
  }
  return r;
}
class uf {
  vector<long long int> v;
  vector<long long int> sz;

 public:
  uf(long long int n) {
    v.resize(n + 1);
    iota(v.begin() + 1, v.end(), 1);
    sz.resize(n + 1, 1);
  }
  long long int root(long long int b) {
    while (v[b] != b) {
      b = v[b];
    }
    return b;
  }
  void u(long long int a, long long int b) {
    long long int ra = root(a);
    long long int rb = root(b);
    if (ra == rb) return;
    if (sz[ra] < sz[rb]) {
      v[ra] = v[rb];
      sz[rb] += sz[ra];
    } else {
      v[rb] = v[ra];
      sz[ra] += sz[rb];
    }
  }
  bool first(long long int a, long long int b) { return (root(a) == root(b)); }
};
vector<long long int> matmul(vector<long long int> a, vector<long long int> b) {
  vector<long long int> c(4, 0);
  c[0] = (a[0] % mod * b[0] % mod + a[1] % mod * b[2] % mod) % mod;
  c[1] = (a[0] % mod * b[1] % mod + a[1] % mod * b[3] % mod) % mod;
  c[2] = (a[2] % mod * b[0] % mod + a[3] % mod * b[2] % mod) % mod;
  c[3] = (a[2] % mod * b[1] % mod + a[3] % mod * b[3] % mod) % mod;
  return c;
}
vector<long long int> id = {1, 0, 0, 1};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> v(n + 1, 0);
  for (long long int i = 1; i <= n; i++) {
    long long int a;
    cin >> a;
    if (a == i) v[i] = 1;
  }
  long long int i = 1;
  long long int ans = 0;
  while (i <= n) {
    if (v[i] == 0) {
      i++;
      continue;
    }
    long long int j = i;
    long long int cnt = 1;
    while (j + 1 <= n and v[j + 1] == v[j]) {
      cnt++;
      j++;
    }
    ans = ans + (cnt > 1 ? cnt - 1 : 1);
    i = j + 1;
  }
  cout << ans;
}
