If your values are all formatted the same way, you can also use the Mid() function:
var num = Number(Mid($feature.RouteName, 5, 4))
return num + " km"
If you have differing formats (eg also routes with 5 or 3 digits), you can use the Replace() function:
var txt = Split($feature.RouteName, "_")[1]
var num = Number(Replace(txt, "KM", ""))
return num + " km"
Have a great day!
Johannes