Utility to find edit distance