Edit distance problem