import std.stdio, std.string, std.ascii;

immutable mod = cast(long)(1e9 + 7);

void main(){
	string buf = readln.chomp;
	enum Func_t{
		EXPR, TERM, FACTOR,
	}
	enum Proc_t{
		EXPR_INIT, EXPR_OR,
		TERM_INIT, TERM_AND,
		FACTOR_INIT, FACTOR_NOT, FACTOR_EXPR,
		END,
	}
	class FuncState{
		Func_t type;
		Proc_t proc;
		long t, f, sum;
		this(){}
		this(Func_t type, Proc_t proc, long t = 1, long f = 1, long sum = 1){
			this.type = type;
			this.proc = proc;
			this.t = t;
			this.f = f;
			this.sum = sum;
		}
	}

	static FuncState[cast(int)(3e6)] stack;
	int p = 0, st = 0, L = buf.length;

	stack[st++] = new FuncState(Func_t.EXPR, Proc_t.EXPR_INIT);

	for(;st;){
		FuncState cur = stack[st-1];
		const FuncState prev = stack[st];

		if(cur.type == Func_t.EXPR){
			if(cur.proc == Proc_t.EXPR_INIT){
				stack[st++] = new FuncState(Func_t.TERM, Proc_t.TERM_INIT);
				cur.proc = Proc_t.EXPR_OR;
				continue;
			}
			else if(cur.proc == Proc_t.EXPR_OR){
				cur.f = cur.f * prev.f % mod;
				cur.sum = cur.sum * prev.sum % mod;

				if(p < L && buf[p] == '|'){
					++p;
					stack[st++] = new FuncState(Func_t.TERM, Proc_t.TERM_INIT);
					continue;
				}
				else{
					cur.t = (cur.sum - cur.f + mod) % mod;
				}
			}
		}
		else if(cur.type == Func_t.TERM){
			if(cur.proc == Proc_t.TERM_INIT){
				stack[st++] = new FuncState(Func_t.FACTOR, Proc_t.FACTOR_INIT);
				cur.proc = Proc_t.TERM_AND;
				continue;
			}
			else if(cur.proc == Proc_t.TERM_AND){
				cur.t = cur.t * prev.t % mod;
				cur.sum = cur.sum * prev.sum % mod;
			}
			if(p < L && buf[p] == '&'){
				++p;
				stack[st++] = new FuncState(Func_t.FACTOR, Proc_t.FACTOR_INIT);
				continue;
			}
			else{
				cur.f = (cur.sum - cur.t + mod) % mod;
			}
		}
		else if(cur.type == Func_t.FACTOR){
			if(cur.proc == Proc_t.FACTOR_INIT){
				if(buf[p] == 'x'){
					for(++p;p<L && isDigit(buf[p]); ++p){}
					cur.t = cur.f = 1;
					cur.sum = cur.t + cur.f;
				}
				else if(buf[p] == '~'){
					++p;
					stack[st++] = new FuncState(Func_t.FACTOR, Proc_t.FACTOR_INIT);
					cur.proc = Proc_t.FACTOR_NOT;
					continue;
				}
				else if(buf[p] == '('){
					++p;
					stack[st++] = new FuncState(Func_t.EXPR, Proc_t.EXPR_INIT);
					cur.proc = Proc_t.FACTOR_EXPR;
					continue;
				}
			}
			else if(cur.proc == Proc_t.FACTOR_NOT){
				cur.t = prev.f;
				cur.f = prev.t;
				cur.sum = prev.sum;
			}
			else if(cur.proc == Proc_t.FACTOR_EXPR){
				++p;
				cur.t = prev.t;
				cur.f = prev.f;
				cur.sum = prev.sum;
			}
		}
		cur.proc = Proc_t.END;
		--st;
	}

	writeln(stack[0].t);
}