#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MOD = 998244353;
const int MX = 1000010;
int pw(int a, int b) {
  if (b == 0) return 1;
  int res = pw(a, b / 2);
  res = 1ll * res * res % MOD;
  if (b & 1) res = 1ll * res * a % MOD;
  return res;
}
int fact[MX];
int factinv[MX];
int getC(int n, int k) {
  if (k > n || k < 0) return 0;
  int div = 1ll * factinv[k] * factinv[n - k] % MOD;
  return 1ll * fact[n] * div % MOD;
}
int psum1[MX];
int psum2[MX];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  int a1 = 0, a2 = 0, b1 = 0, b2 = 0;
  int q = 0;
  for (int i = 0; i < n; i++) {
    q += s[i] == '?';
    a2 += s[i] == ')';
  }
  b2 = q;
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MX; i++) {
    fact[i] = 1ll * fact[i - 1] * i % MOD;
    factinv[i] = pw(fact[i], MOD - 2);
  }
  for (int i = 1; i < n + 2; i++) {
    psum2[i] = psum2[i - 1] + getC(q, i - 1);
    if (q) psum1[i] = psum1[i - 1] + getC(q - 1, i - 1);
    if (psum2[i] >= MOD) psum2[i] -= MOD;
    if (psum1[i] >= MOD) psum1[i] -= MOD;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    b2 -= s[i] == '?';
    a2 -= s[i] == ')';
    if (s[i] != ')') {
      int f = a2 + b2 - a1 - 1;
      if (f >= 0) {
        if (b2 + b1 == q)
          ans += psum2[f + 1];
        else
          ans += psum1[f + 1];
        if (ans >= MOD) ans -= MOD;
      }
    }
    b1 += s[i] == '?';
    a1 += s[i] == '(';
  }
  cout << ans;
}
