Remove non-digit characters from user input before str-to-int conversion