from collections import defaultdict

from itertools import product, groupby

from math import pi

from collections import deque

from bisect import bisect, bisect_left, bisect_right

INF = 10 ** 10





def main():

    N = int(eval(input()))

    p_list = list(map(int, input().split()))

    a_list = list(range(1, N + 1))

    ans = 0

    i = 0

    while i < N:

        if i + 1 < N and p_list[i] == a_list[i] and p_list[i + 1] == a_list[i + 1]:

            ans += 1

            i += 2

        elif p_list[i] == a_list[i]:

            ans += 1

            i += 2

        else:

            i += 1

    print(ans)



if __name__ == '__main__':

    main()

from collections import defaultdict

from itertools import product, groupby

from math import pi

from collections import deque

from bisect import bisect, bisect_left, bisect_right

INF = 10 ** 10





def main():

    N = int(eval(input()))

    p_list = list(map(int, input().split()))

    ans = 0

    i = 0

    while i < N:

        if p_list[i] == i + 1:

            ans += 1

            i += 2

        else:

            i += 1

    print(ans)



if __name__ == '__main__':

    main()

from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right

INF = 10**10


def main():
    N = int(eval(input()))
    p_list = list(map(int, input().split()))
    a_list = list(range(1, N + 1))
    ans = 0
    i = 0
    while i < N:
        if i + 1 < N and p_list[i] == a_list[i] and p_list[i + 1] == a_list[i + 1]:
            ans += 1
            i += 2
        elif p_list[i] == a_list[i]:
            ans += 1
            i += 2
        else:
            i += 1
    print(ans)


if __name__ == "__main__":
    main()

from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right

INF = 10**10


def main():
    N = int(eval(input()))
    p_list = list(map(int, input().split()))
    ans = 0
    i = 0
    while i < N:
        if p_list[i] == i + 1:
            ans += 1
            i += 2
        else:
            i += 1
    print(ans)


if __name__ == "__main__":
    main()

-    a_list = list(range(1, N + 1)) -        if i + 1 < N and p_list[i] == a_list[i] and p_list[i + 1] == a_list[i + 1]: -            ans += 1 -            i += 2 -        elif p_list[i] == a_list[i]: +        if p_list[i] == i + 1: