def change_transpose_distance(s1, s2):
    """ Return the minimal number of changes and transpositions needed to get from s1 to s2. """
    n = max(len(s1), len(s2))
    s1, s2 = s1.rjust(n, '0'), s2.rjust(n, '0')
    score = [0]
    for i in range(len(s1)):
        cost = score[i] + (0 if s1[i] == s2[i] else 1)
        if i:
            cost = min(cost, score[i - 1] + (1 if set(s1[i - 1:i + 1]) ==
                set(s2[i - 1:i + 1]) else 2))
        score.append(cost)
    return score[-1]
