Given two strings `word1` and `word2`, return the minimum number of single-character insertions, deletions, or substitutions needed to turn word1 into word2.