#!/usr/bin/env python3

import sys





def solve(N: int, p: "List[int]"):



    ans = 0

    

    for i in range(N-1):

        

        if(i+1 == p[i]):

            p[i],p[i+1] = p[i+1],p[i]

            ans += 1



    for i in range(N-1,-1,-1):

        if(i+1 == p[i]):

            p[i],p[i-1] = p[i-1],p[i]

            ans += 1    



    print(ans)



    return





# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, p)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys





def solve(N: int, p: "List[int]"):



    ans = 0

    

    for i in range(N-1):

        if(i+1 == p[i]):

            p[i],p[i+1] = p[i+1],p[i]

            ans += 1



    if(N == p[N-1]):

        ans += 1



    print(ans)



    # for i in range(N-1):

        

    #     if(i+1 == p[i]):

    #         p[i],p[i+1] = p[i+1],p[i]

    #         ans += 1



    # for i in range(N-1,-1,-1):

    #     if(i+1 == p[i]):

    #         p[i],p[i-1] = p[i-1],p[i]

    #         ans += 1    



    # print(ans)



    return





# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"

    solve(N, p)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[int]"):
    ans = 0
    for i in range(N - 1):
        if i + 1 == p[i]:
            p[i], p[i + 1] = p[i + 1], p[i]
            ans += 1
    for i in range(N - 1, -1, -1):
        if i + 1 == p[i]:
            p[i], p[i - 1] = p[i - 1], p[i]
            ans += 1
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[int]"):
    ans = 0
    for i in range(N - 1):
        if i + 1 == p[i]:
            p[i], p[i + 1] = p[i + 1], p[i]
            ans += 1
    if N == p[N - 1]:
        ans += 1
    print(ans)
    # for i in range(N-1):
    #     if(i+1 == p[i]):
    #         p[i],p[i+1] = p[i+1],p[i]
    #         ans += 1
    # for i in range(N-1,-1,-1):
    #     if(i+1 == p[i]):
    #         p[i],p[i-1] = p[i-1],p[i]
    #         ans += 1
    # print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)


if __name__ == "__main__":
    main()

-    for i in range(N - 1, -1, -1): -        if i + 1 == p[i]: -            p[i], p[i - 1] = p[i - 1], p[i] -            ans += 1 +    if N == p[N - 1]: +        ans += 1 +    # for i in range(N-1): +    #     if(i+1 == p[i]): +    #         p[i],p[i+1] = p[i+1],p[i] +    #         ans += 1 +    # for i in range(N-1,-1,-1): +    #     if(i+1 == p[i]): +    #         p[i],p[i-1] = p[i-1],p[i] +    #         ans += 1 +    # print(ans)