import Foundation

let s = readLine()!
let t = readLine()!

var minCost = Int.max

for prefix in 0..<t.count - 1 {
    guard prefix < minCost else { break }
    for suffix in 0..<t.count - prefix {
        let subS = s.dropFirst(prefix).dropLast(suffix)
        let subT = t.dropFirst(prefix).dropLast(suffix)
        let cost = prefix + suffix
        if cost < minCost && subS.contains(subT) {
            minCost = cost
            break
        }
    }
}

print(minCost)
