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

input.each do |line|
    k = Array.new(line.length)

    fin = false
    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] = 0
            if i==line.length-1
                fin = true
            end
            break if fin
        end
        break if fin
    end

    0.upto(line.length - 1) do |n|
        k.each_with_index do |e, l|
            next unless e == n
            d = {}
            (l+1).upto(line.length-1) do |i|
                d[line[i]] = (d[line[i]] || 0) + 1
                if !k[i] && d.values.count {|e| e%2 == 1} <= 1
                    k[i] = n+1
                    if i==line.length-1
                        fin = true
                    end
                end
                break if fin
            end
            break if fin
        end
        break if fin
    end

    puts k.last+1

end
