#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long mod = 998244353;
long long fac[N], inve[N];
long long pre1[N], pre2[N];
long long ksm(long long a, long long p) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * a % mod;
    a = a * a % mod;
    p >>= 1;
  }
  return ans;
}
void init() {
  fac[0] = 1;
  for (long long i = 1; i <= 1e6; i++) fac[i] = fac[i - 1] * i % mod;
  inve[1000000] = ksm(fac[1000000], mod - 2);
  for (long long i = 1e6 - 1; i >= 0; i--)
    inve[i] = inve[i + 1] * (i + 1) % mod;
}
long long cal(long long n, long long m) {
  return fac[n] * inve[m] % mod * inve[n - m] % mod;
}
long long a, b, c, d;
char s[N];
long long len;
int main() {
  init();
  cin >> s + 1;
  len = strlen(s + 1);
  for (int i = 1; i <= len; i++) {
    if (s[i] == ')') b++;
    if (s[i] == '?') d++;
  }
  for (int i = d; i >= 0; i--) pre1[i] = (pre1[i + 1] + cal(d, i)) % mod;
  for (int i = d - 1; i >= 0; i--)
    pre2[i] = (pre2[i + 1] + cal(d - 1, i)) % mod;
  long long ans = 0;
  for (int i = 1; i <= len; i++) {
    if (s[i] == '?')
      c++, d--;
    else if (s[i] == '(')
      a++;
    else
      b--;
    if (s[i] == '(')
      ans = (ans + pre1[max(0LL, a - b + c)]) % mod;
    else if (s[i] == '?')
      ans = (ans + pre2[max(0LL, a - b + c)]) % mod;
  }
  cout << ans << endl;
}
