// Author: Jason Cobb
/// School: Triangle Math and Science Academy
/// Division: I-3
/// Contest 2

import kotlin.math.max
import kotlin.math.min

private data class StepResult(
    val newFirstString: String,
    val newSecondString: String,
    val changed: Boolean
)

private fun removeSameCharsAtSameLocations(firstString: String, secondString: String): StepResult {
    var firstResult: String = ""
    var secondResult: String = ""
    var changed: Boolean = false

    val minSize = min(firstString.length, secondString.length)

    for (index in 0 until minSize) {
        val firstChar = firstString[index]
        val secondChar = secondString[index]

        if (firstChar != secondChar) {
            firstResult += firstChar
            secondResult += secondChar
        } else {
            changed = true
        }
    }

    firstResult += firstString.substring(minSize)
    secondResult += secondString.substring(minSize)

    return StepResult(firstResult, secondResult, changed)
}

private fun String.withoutCharAt(index: Int): String {
    return this.substring(0, index) + this.substring(index + 1)
}

private fun removeCharsIfWouldCauseMatch(initalFirst: String, initialSecond: String): StepResult {
    var firstString: String = initalFirst
    var secondString: String = initialSecond
    var index: Int = 0

    var changed: Boolean = false

    while (index < firstString.length && index < secondString.length) {
        val canDeleteAtAll = firstString[index] != secondString[index]

        if (canDeleteAtAll) {
            val canDeleteFromFirst = index < (firstString.length - 1) && firstString[index + 1] == secondString[index]
            val canDeleteFromSecond = index < (secondString.length - 1) && secondString[index + 1] == firstString[index]

            if (canDeleteFromSecond) {
                secondString = secondString.withoutCharAt(index)
                changed = true
            } else if (canDeleteFromFirst) {
                firstString = firstString.withoutCharAt(index)
                changed = true
            }
        }

        if (changed) break

        ++index
    }

    return StepResult(firstString, secondString, changed)
}

private fun printIntermediate(stepResult: StepResult) {
    if (!stepResult.changed) return
}

private fun oneWholeStep(firstString: String, secondString: String): StepResult {
    val firstSubStepResult = removeSameCharsAtSameLocations(firstString, secondString)
    printIntermediate(firstSubStepResult)

    val secondSubStepResult = removeCharsIfWouldCauseMatch(firstSubStepResult.newFirstString, firstSubStepResult.newSecondString)
    printIntermediate(secondSubStepResult)

    val changed = firstSubStepResult.changed || secondSubStepResult.changed

    return StepResult(secondSubStepResult.newFirstString, secondSubStepResult.newSecondString, changed)
}

private data class ProcessResult(val firstString: String, val secondString: String)

private fun fullProcess(firstString: String, secondString: String): ProcessResult {
    var result: StepResult = oneWholeStep(firstString, secondString)

    while (result.changed) {
        result = oneWholeStep(result.newFirstString, result.newSecondString)
    }

    return ProcessResult(result.newFirstString, result.newSecondString)
}

private fun samenessFactor(result: ProcessResult): Int {
    val firstString = result.firstString
    val secondString = result.secondString
    val minSize = min(firstString.length, secondString.length)
    val maxSize = max(firstString.length, secondString.length)

    val letterDiffSum = result.firstString.zip(result.secondString).map { it.first - it.second }.sum()

    return letterDiffSum + (maxSize - minSize)
}

fun main() {
    repeat(5) { _ ->
        try {
            val line = readLine() ?: error("Must have input!")
            val (firstString, secondString) = line.split(" ").filterNot { it.isBlank() }

            println(samenessFactor(fullProcess(firstString, secondString)))
        } catch (t: Throwable) {
            t.printStackTrace()
        }
    }
}