using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static void swap(ref long x,ref long y)
        {
            var tmp = x;
            x = y;
            y = tmp;
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var n = Read();
            var p = Reads();
            long ans = 0;

            if (p[0] == 1) { swap(ref p[0], ref p[1]);  ans++; }  
            for (int i = 1; i < n-1; i++)
            {
                if (p[i] == i + 1)
                {
                    if (p[i - 1] == i) swap(ref p[i], ref p[n - 1]);
                    else if (p[i + 1] == i + 2) swap(ref p[i], ref p[i + 1]);
                    else swap(ref p[i], ref p[n - 1]);
                    ans++;
                }
            }
            if (p[n - 1] == n) { swap(ref p[n - 2], ref p[n - 1]); ans++; }

            Console.WriteLine(ans);





            Console.Out.Flush();
        }
    }
}