S = gets.chomp
T = gets.chomp

len_s = S.length
len_t = T.length

max_len = 0

0.upto(len_t-1).each{ |a|
  a.upto(len_t-1){ |b|
    s_last = (len_s - 1) - ((len_t - 1) - b)
    if S[a..s_last].include? T[a..b]
      if max_len < b - a + 1
        max_len = b - a + 1
      end
    end
  }
}

puts (len_t - max_len)
