MOD = 1_000_000_007

class Array
	def &(a)
		t1, f1 = self
		t2, f2 = a
		[t1 * t2 % MOD, (t1 * f2 + f1 * t2 + f1 * f2) % MOD]
	end

	def |(a)
		t1, f1 = self
		t2, f2 = a
		[(t1 * t2 + t1 * f2 + f1 * t2) % MOD, f1 * f2 % MOD]
	end

	def ~@
		reverse	
	end
end

e = ?( + gets.chomp + ?)
0 while e.gsub!("~~", "")
0 while e.gsub!("~x", "x")

rev_polish = []
op_stack = []
e.scan(/~?\(|\)|~|&|\||x\d+/) do |token|
	case token
	when /~?\(/
		op_stack << token
	when ?)
		loop do
			op = op_stack.pop
			if op == "~("
				rev_polish << ?~
				break
			elsif op == ?(
				break
			else
				rev_polish << op
			end
		end
	when ?&
		op_stack << token
	when ?|
		while op_stack[-1] == ?&
			rev_polish << op_stack.pop
		end
		op_stack << token
	else
		rev_polish << ?x
	end
end

stack = []
rev_polish.each do |x|
	if x == ?x
		stack << [1, 1]
	elsif x == ?~
		stack << ~stack.pop
	else
		stack << stack.pop.send(x, stack.pop)
	end
end

p stack[0][0]