# frozen_string_literal: true

s = gets.chomp
T = gets.chomp

ans = T.size
(0..(T.size - 1)).each do |start|
  count = start
  T.size.times.reverse_each do |length|
    next if start > length

    if index = s.index(T[start..length])
      ans = count if ans > count && index >= start
    end
    count += 1
  end
end

puts ans
