def distance(first, second):
    if (first == ''):
        return len(second)
    if (second == ''):
        return len(first)
    if (first[0] == second[0]):
        return distance(first[1:], second[1:])
    substitution = (1 + distance(first[1:], second[1:]))
    deletion = (1 + distance(first[1:], second))
    insertion = (1 + distance(first, second[1:]))
    return min(substitution, deletion, insertion)
def distance(first, second):
    if (first == ):
        return len(second)
    if (second == ):
        return len(first)
    if (first[0] == second[0]):
        return distance(first[1:], second[1:])
    substitution = (1 + distance(first[1:], second[1:]))
    deletion = (1 + distance(first[1:], second))
    insertion = (1 + distance(first, second[1:]))
    return min(substitution, deletion, insertion)