You could use cx, requjiires more push and pop.
Register dh has the char the user input. The current version sets the error code to this value. This count be used as a counter instead.
You must assume int 21 alters any registers. So you must save the register with a push and later pop. The program already saves the dx register pair.
See if you can modify the program to use dl as a counter. Or use cx if you wish.