def main():
    _ = int(input())
    p_list = [int(p) for p in input().split()]

    i, cnt = 0, 0
    while (i < len(p_list)):
        block = 0
        while (i < len(p_list)):
            if p_list[i] == i+1:
                block += 1
                i += 1
            else:
                i += 1
                break
        if block == 1 or block == 2:
            cnt += 1
        elif block > 2:
            cnt += block - 1
    print(cnt)


if __name__ == "__main__":
    main()