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

if t.isEmpty {
  print(s.isEmpty ? 0 : -1)
  exit(0)
}

let S = Array(s)
let T = Array(t)

var ans = T.count

func diff(_ S: [Character], _ T: [Character], _ index: Int) -> Int {

  var diff = 0
  for i in 0..<T.count {
    if T[i] != S[index + i] {
      diff += 1
    }
  }
  
  return diff
}

for i in 0...S.count - T.count {
  ans = min(ans, diff(S, T, i))
  if ans == 0 {
    break
  }
}

print(ans)