Find cost of all characters in both strings
for ( $ i = 0 ; $ i < $ m ; ++ $ i ) $ cost += $ X [ $ i ] - '0' ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) $ cost += $ Y [ $ i ] - '0' ; return $ cost - lcs ( $ X , $ Y , $ m , $ n ) ; }