def main():
    N = int(input())
    P = tuple(map(int, input().split()))

    p = []
    ans = 0
    prev = 0
    for i, n in enumerate(P):
        if i + 1 == n:
            p.append(n)

    ans = 0
    cont = 0
    for i in range(1, len(p)):
        if p[i] == p[i-1] + 1:
            cont += 1
        else:
            if i == 1:
                ans = 2
            else:
                ans += cont + 1
            cont = 0
    else:
        ans += cont

    print(ans)

main()
