Implement atoi to convert a string to an integer.