Define as the length of the LCS (Longest Common Subsequence) of the first characters of A and the first characters of B. Why this definition? At each step, you're either matching characters or skipping one.
You need to track progress in both strings independently. Base cases: for all (empty A has no common subsequence with anything). for all (empty B has no common subsequence with anything).