Fix program logic to work with Russian strings