find the longest common subsequence