#include using namespace std; using ll = long long; void print_list(vector a){ for(auto i:a){ cout << i << ' '; } cout << '\n'; } int main(){ int n; string s; cin >> n >> s; vector stack; for(auto i:s){ if(i == '('){ stack.push_back(-1); stack.push_back(0); } else{ ll ansver = stack.back(); while(stack.back() != -1){ stack.pop_back(); if(stack.back() != 0 && stack.back() != -1) ansver *= stack.back(); //cout << ansver << '\n'; } stack.pop_back(); stack.push_back(ansver+1); } //print_list(stack); } cout << stack[0] << '\n'; }