def main():
    n = int(input())
    ps = list(map(int, input().split()))
    bf = -1
    ans = 0
    minus = 0
    for i in range(n):
        # print(i+1)
        if ps[i] == i+1:
            ans += 1
            if bf == -1:
                bf = i
            else:
                if bf + 1 == i:
                    minus += 1
                bf = -1

    ans -= minus
    print(ans)


if __name__ == "__main__":
    main()
