# A Naive recursive Python implementation of LCS problem 
def lcs(X, Y, m, n): 
  
    if m == 0 or n == 0: 
       return 0; 
    elif X[m-1] == Y[n-1]: 
       return 1 + lcs(X, Y, m-1, n-1); 
    else: 
       return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n)); 
  

# Main function
if __name__ == '__main__':
	X = "CADENA"
	Y = "SUBCADENA"
	print("\nLength of LCS is ", lcs(X , Y, len(X), len(Y)))