#include<iostream>
#define M 1000000007
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

P parse(string s){
  P res = P(0,0);
  for(int i=0;i<2;i++){
    //cout << s << endl;
    int k = 0,pos = 0;
    while(pos<s.size()){
      if(s[pos] == '(')k++;
      if(s[pos] == ')')k--;
      if(!k && s[pos] == '|'){
	P a = parse(s.substr(0,pos));
	P b = parse(s.substr(pos+1,(int)s.size()-pos-1));
	res.first = (res.first + a.first * b.first) % M;
	res.first = (res.first + a.second * b.first) % M;
	res.first = (res.first + a.first * b.second) % M;
	res.second = (res.second + a.second * b.second) % M;
	//cout << res.first << " " << res.second << endl;
	return res;
      }
      pos++;
    }
    k = 0,pos = 0;
    while(pos<s.size()){
      if(s[pos] == '(')k++;
      if(s[pos] == ')')k--;
      if(!k && s[pos] == '&'){
	P a = parse(s.substr(0,pos));
	P b = parse(s.substr(pos+1,(int)s.size()-pos-1));
	res.first = (res.first + a.first * b.first) % M;
	res.second = (res.second + a.second * b.first) % M;
	res.second = (res.second + a.first * b.second) % M;
	res.second = (res.second + a.second * b.second) % M;
	//cout << res.first << " " << res.second << endl;
	return res;
      }
      pos++;
    }
    
    if(s[0] == '(' && s[(int)s.size()-1] == ')'){
      s.erase(s.begin());
      s.erase(s.end()-1);
    }else break;
  }


  if(s[0]=='~'){
    P a = parse(s.substr(1,(int)s.size()-1));
    res.first = a.second;
    res.second = a.first;
  }else{
    res.first = 1;
    res.second = 1;
  }
  //cout << res.first << " " << res.second << endl;
  return res;
}

int main(){
  string s;
  cin >> s;
  P p = parse(s);
  cout << p.first << endl;
}