string reduction problem