use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::mem::swap;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut p: [usize;n],
    }

    let mut cnt = 0;
    let mut flag: Vec<bool> = vec![true;n];
    for i in 0..n {
        if p[i]==i+1 {
            flag[i] = false;
        }
    }
    debug!(flag);
    for i in 0..n-1 {
        if flag[i]==false {
            if p[i]==i+1 || p[i+1]==i+2 {
                p.swap(i,i+1);
                cnt += 1;
            }
            flag[i+1] = true;
        } 
    }
    println!("{}", cnt);
}
