def main():
    N = int(input())
    P = [int(i) for i in input().split()]
    ans = 0
    pre = -1
    flag = False
    for i, p in enumerate(P):
        if i+1 == p:
            ans += 1
            if i > 0 and i == pre:
                flag = True
        elif flag and i+1 != p:
            ans -= 1
            flag = False
        pre = p
    if flag:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()
