require 'ripper'
require 'pp'


def check_par(tree)
	#pp tree
	node, children = tree	
	if node == :paren
		if children.is_a?(Array)
			return true if children.size == 1 && children[0].is_a?(Array) && children[0][0] == :paren
		end
	end

	if children.is_a?(Array)
		return children.any?{|x| check_par(x)}
	end
end


def b_eval(s)
	begin
		raise if s =~ /\(\d*\)/
		e = s.gsub(/\d+/){|x| "0b" + x}
		raise if check_par(Ripper.sexp(e))
		eval e
	rescue Exception
		-Float::INFINITY
	end
end

s = gets.chomp
k = s.count ?.

x = nil
if k == 0
	x = b_eval(s)
else
	x = %w|0 1 + - * ( )|.repeated_permutation(k).map {|perm|
		d = s.dup
		perm.each {|c| d.sub!(?., c)}
		x = b_eval(d)
		x
	}.max
end
p x == -Float::INFINITY ? -1 : x