Characteristic functions of almost solvable extensions of Hermitian operators