找规律题,结论是2k12^{k-1}kk为左右括号完全匹配个数,例如(())匹配个数1,()()匹配个数为2;简单正面就是如果一个字符串是...XX ...是完全匹配的括号长度,xx是新加入的完全匹配的长度,对于新加进来后我们有两种操作可以取:切或者不切,对于每一种操作前面的状态都是不会产生影响,所以其实就相当于每有一队完全匹配的答案就*2,但是也要注意如果出现不匹配那么结果就是-1,比如())或者()())这种都是不匹配的情况。

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map>

# define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
# define x1 sb
# define y1 dsb
# define x2 ssb
# define y2 ddsb
// cout<<fixed<<setprecision(n) 
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII; 
const int mod=1e9+7;
const int N=5e5+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846; 
double e = exp(1);

int T,n,m,k,t,maxn,ans,p;
int a[10];
int qsm(int a,int b){
	 int res = 1;
	 while(b){
	 	 if(b&1) res = res * a % mod;
	 	 a = a * a % mod;
	 	 b >>= 1;
	 }
	 return res % mod;
}
void solve(){
	     int cnt1 = 0 ;
         string s;
         cin >> s;
         int i = 0;
         bool ok = true;
         for(int i = 0 ; i < s.size() ; i ++ ){
		 	 if(s[i] == '(') cnt1++;
		 	 if(s[i] == ')') cnt1--;
		 	 if(cnt1 < 0) {
			  	 ok = false;
			  	 break;
			  }
			  if(cnt1 == 0) ans++;
		 }
		 
        if(!ok || cnt1 != 0)
		   cout<<"-1";
        else
           cout<<qsm(2,ans-1)%mod;
}	  
/*
1 2 9 4 0 5 9 7 

*/
signed main(){  
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
    
      //cin >> T;
    T = 1;
    while(T--){
		solve();
	} 
    return 0; 
}