@arg = gets.chomp
@arg_len = @arg.length
@dp_table = {}

def calc_erasable_index(pattern)
    unless @dp_table[pattern]
        @dp_table.store(pattern,@arg_len - pattern.length)
        if /01/ =~ pattern || /10/ =~ pattern
            calc_erasable_index($` + $')
        end
    end        
    return 0
end


calc_erasable_index(@arg)
print @dp_table.values.max