use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        let x:usize = read();
        if x == i+1 {
            v.push(x);
        }
    }
    let mut ans = v.len();
    if ans > 1 {
        for i in 0..v.len()-1 {
            if v[i] == i+1 && v[i+1] == i+2 {
                ans -= 1;
            }
        }
    }
    println!("{}", ans);
}
