String-to-int conversion function