def lcs(str1, str2):
    """return the lenth of lcs of [str1] and [str2]"""
    len1, len2 = len(str1), len(str2)
    if len1 == 0 or len2 == 0:
        return 0
    dpf = []
    for i in range(len1 + 1):
        lis = []
        for j in range(len2 + 1):
            lis.append(0)
        dpf.append(lis)
    for i in range(1, len1 + 1):
        for j in range(1, len2 + 1):
            if str1[i - 1] == str2[j - 1]:
                dpf[i][j] = dpf[i - 1][j - 1] + 1
            else:
                dpf[i][j] = max(dpf[i][j - 1], dpf[i - 1][j])
    return dpf[len1][len2]
