s = gets.strip.split('')
t = gets.strip.split('')


res = 0
t.each_with_index do |e, i|
  mx = 0
  start1 = i
  start2 = -1
  flg = false
  s.each_with_index do |e1, j|
    if flg == true
      if t[start1] != e1
        if i <= start2 && t.size - start1  <= s.size - j - 1 && start2 != -1
          res = [res, mx].max
        end
        mx = 0
        start1 = i
        start2 = -1
        flg = false
      end
    end
    if t[start1] == e1
      start2 = j if mx.zero?
      start1 += 1
      mx += 1
      flg = true
    end
    if t[start1 - 1] == e1 && s.size - 1 == j
      if i <= start2 && t.size - start1  <= s.size - j - 1 && start2 != -1
        res = [res, mx].max
      end
      mx = 0
      start1 = i
      start2 = -1
    end
  end
end
puts t.size - res