Lower vertex count using while loop

I was wondering if lowering the vertex count for a stroke mesh with 50 vertices to a target count was possible?

Maybe using a while loop to dissolve or merge by distance until it reaches that target number

import bpy

import mathutils

import bmesh

ob = bpy.context.object
me = ob.data

count = len(me.vertices)

min = 10

while count >= min:
    bpy.ops.mesh.dissolve_limited(angle_limit=0.5 + 0.5)


but im having issues with the script.