On the complexity of the Whitehead minimization problem