#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

int main(){
	const LL mod = 1000000007LL;

	int pra[128] = {}, prs[128] = {};
	pra['|'] = 15;
	pra['&'] = 25;
	pra[')'] = 5;

	prs['|'] = 16;
	prs['&'] = 26;
	prs['~'] = 34;
	prs['('] = 4;

	string s;
	cin >> s;
	s += ')';

	vector<pii> v(1, pii('(', -1));
	v.reserve(s.size());

	for(size_t i = 0; i < s.size(); ++i){
		int c = s[i];
		if(c == 'x'){
			v.push_back(pii(1, 1));
		}
		else if(!isdigit(c)){
			if(c != '(' && c != '~'){
				while(v.size() > 1){
					int op = v[v.size() - 2].first;

					if(prs[op] < pra[c]){ break; }

					pii y = v.back();
					v.pop_back();
					v.pop_back();

					if(op == '~'){
						v.push_back(pii(y.second, y.first));
					}
					else if(op == '&'){
						pii x = v.back();
						LL tr = (LL)x.first * y.first;
						LL fl = (LL)x.first * y.second + x.second * LL(y.first + y.second);
						v.back() = pii(tr % mod, fl % mod);
					}
					else if(op == '|'){
						pii x = v.back();
						LL tr = (LL)x.second * y.first + x.first * LL(y.first + y.second);
						LL fl = (LL)x.second * y.second;
						v.back() = pii(tr % mod, fl % mod);
					}
					else{
						throw op;
					}
				}
			}
			
			if(c == ')'){
				v[v.size() - 2] = v.back();
				v.pop_back();
			}
			else{
				v.push_back(pii(c, -1));
			}
		}
	}
	
	cout << v[0].first << endl;
}