def main():
    n, *p = map(int, open(0).read().split())
    res = []
    tmp = False
    for i, j in enumerate(p, 1):
        b = (i == j) ^ tmp
        res.append(b)
        tmp = b

    ans = sum(res)
    print(ans)


if __name__ == '__main__':
    main()
