LCS similarity calculation