input = $stdin.read.split("\n")

input.each do |line|
    k = Array.new(line.length).map{[]}
    k[0] = []

    l = 0
    n = 0

    x = {}

    d = {}
    0.upto(line.length-1) do |i|
        d[line[i]] = (d[line[i]] || 0) + 1
        if d.values.count {|e| e%2 == 1} <= 1
            k[i].push(n)
        end
    end

    # p k
    0.upto(line.length - 1) do |n|
        k.each_with_index do |e, l|
            next unless e.min == n
            d = {}
            (l+1).upto(line.length-1) do |i|
                d[line[i]] = (d[line[i]] || 0) + 1
                if d.values.count {|e| e%2 == 1} <= 1
                    k[i].push(n+1)
                    k[i] = k[i].uniq
                end
            end
        end
        # p k
    end

    puts k.last.min+1

    # puts ""
end
