For list ["d", "ad", "acd", "abc", "abcd"] the result from the code is 3 while the maximum chain should be 4.