#include <iostream>
#include <string>

using std::cin, std::cout, std::string;
using ull = unsigned long long;

constexpr size_t MAX_N {(size_t)3e5+5}, MOD {998244353};
string s;
ull left_ok[MAX_N], stk[MAX_N], stk_size, left_index[MAX_N], ans;

int main(){
    cin>>s;

    for(size_t i {1};i<=s.size();i++){
        if(s[i-1]=='('){
            stk[stk_size++] = i;
        }else if(stk_size>0){
            left_index[i] = stk[--stk_size];
            left_ok[i] = (left_ok[left_index[i]-1] + left_index[i]) % MOD;
            ans = ( ans + left_ok[i] * (s.size() - i + 1)) % MOD;
        }
    }
    cout<<ans<<'\n';
}