This paper investigates several cost-sparsity induced optimal input selection problems for structured systems. Given are an autonomous system and a prescribed set of input links, where each input link has a non-negative cost. The problems include selecting the minimum cost of input links, and selecting the input links with the smallest possible cost with a bound on their cardinality, all to ensure system structural controllability. Current studies show that in the dedicated input case (i.e., each input can actuate only a state variable), the former problem is polynomially solvable by some graph-theoretic algorithms, while the general nontrivial constrained case is largely unexploited. We show these problems can be formulated as equivalent integer linear programming (ILP) problems. Subject to a certain condition on the prescribed input configurations that contains the dedicated input one as a special case, we demonstrate that the constraint matrices of these ILPs are totally unimodular. This property allows us to solve those ILPs efficiently simply via their linear programming (LP) relaxations, leading to a unifying algebraic method for these problems with polynomial time complexity. It is further shown those problems could be solved in strongly polynomial time, independent of the size of the costs and cardinality bounds. Finally, an example is provided to illustrate the power of the proposed method.