#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long moddiv(long long a, long long b) {
  a %= (long long)998244353;
  b %= (long long)998244353;
  for (long long m = (long long)998244353 - 2; m > 0; m /= 2) {
    if (m & 1) {
      a = a * b % (long long)998244353;
    }
    b = b * b % (long long)998244353;
  }
  return a;
}
long long Sn;
char S[1010101];
long long Fa[1010101], iFa[1010101];
long long cs[2][1010101];
long long qn = 0;
long long i, j, k, ans;
long long calc(long long a, long long b, long long c, bool typ) {
  long long bca = b + c - a;
  if (qn < bca) bca = qn;
  if (typ) {
    bca--;
  }
  if (bca < 0) return 0;
  return cs[typ][bca];
}
int main() {
  scanf("%s", S);
  Sn = strlen(S);
  Fa[0] = 1;
  for (i = 0; i < Sn; i++) {
    Fa[i + 1] = Fa[i] * (i + 1) % (long long)998244353;
  }
  iFa[Sn] = moddiv(1, Fa[Sn]);
  for (i = Sn - 1; i >= 0; i--) {
    iFa[i] = iFa[i + 1] * (i + 1) % (long long)998244353;
  }
  long long a = 0, b = 0, c = 0;
  for (i = 0; i < Sn; i++) {
    if (S[i] == ')') b++;
    if (S[i] == '?') c++;
  }
  qn = c;
  if (qn == 0) {
    ans = 0;
    for (i = 0; i < Sn; i++) {
      if (S[i] == '(') {
        a++;
      }
      if (S[i] == ')') {
        b--;
      }
      if (ans < min(a, b)) {
        ans = min(a, b);
      }
    }
    printf("%lld", ans);
    return 0;
  }
  cs[0][0] = cs[1][0] = 1ll;
  for (i = 0; i < c; i++) {
    cs[0][i + 1] =
        cs[0][i] + Fa[c] * iFa[c - i - 1] % (long long)998244353 * iFa[i + 1];
    cs[0][i + 1] %= (long long)998244353;
  }
  for (i = 0; i < c - 1; i++) {
    cs[1][i + 1] = cs[1][i] + Fa[c - 1] * iFa[c - i - 2] %
                                  (long long)998244353 * iFa[i + 1];
    cs[1][i + 1] %= (long long)998244353;
  }
  ans = 0;
  for (i = 0; i < Sn; i++) {
    if (S[i] == ')') {
      b--;
    }
    if (S[i] == '(') {
      a++;
      ans = (ans + calc(a, b, c, false)) % (long long)998244353;
    }
    if (S[i] == '?') {
      c--;
      ans = (ans + calc(a, b, c, true)) % (long long)998244353;
    }
  }
  printf("%lld", ans);
  return 0;
}
