lehvenstein distance func