S = gets.chomp
T = gets.chomp

l = T.length
(0..l).each do |i|
  (0...l).to_a.combination(i).to_a.each do |c|
    s = T.split("").map.with_index{|t, idx| c.include?(idx) ? "[a-z]": t}.join("")

    if !Regexp.new(s).match(S).nil?
      p i
      exit
    end
  end
end