#include <bits/stdc++.h>
using namespace std;
long long sol(string &str) {
  int n = (int)str.size();
  long long mod = 998244353;
  int fs = 1005050;
  vector<long long> fact(fs), ifact(fs), invs(fs);
  fact[0] = ifact[0] = fact[1] = ifact[1] = invs[1] = 1;
  for (int i = 2; i < fs; i++) {
    fact[i] = fact[i - 1] * i % mod;
    invs[i] = mod - invs[mod % i] * (mod / i) % mod;
    ifact[i] = ifact[i - 1] * invs[i] % mod;
  }
  function<long long(int, int)> binom = [&](int a, int b) {
    if (b == 0) return 1LL;
    if (a < b || b < 0) return 0LL;
    return fact[a] * ifact[b] % mod * ifact[a - b] % mod;
  };
  int all_q = 0, all_c = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == ')') all_c++;
    if (str[i] == '?') all_q++;
  }
  vector<long long> psum0(n + 2), psum1(n + 2);
  for (int i = n; i >= 0; i--) {
    psum0[i] = (psum0[i + 1] + binom(all_q, i)) % mod;
    psum1[i] = (psum1[i + 1] + binom(all_q - 1, i)) % mod;
  }
  int c0 = 0, c1 = 0, d2 = 0, d3 = 0;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    int c2 = all_c - d2;
    int c3 = all_q - d3;
    if (str[i] != ')') {
      int b = max(0, c1 + c0 + 1 - c2);
      if (str[i] == '?') {
        res = (res + psum1[b]) % mod;
      } else {
        res = (res + psum0[b]) % mod;
      }
    }
    if (str[i] == ')') d2++;
    if (str[i] == '(') c0++;
    if (str[i] == '?') c1++;
    d3 = c1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  cout << sol(str) << "\n";
  return 0;
}
