#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353, maxn = 1020000;
int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
int sub(int x, int y) { return x - y < 0 ? x - y + MOD : x - y; }
int mul(int x, int y) { return 1LL * x * y % MOD; }
int qpow(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) ret = mul(ret, x);
  return ret;
}
int fac[maxn], ifac[maxn], suf[2][maxn], n;
char s[maxn];
int C(int N, int M) {
  if (M > N) return 0;
  return mul(fac[N], mul(ifac[M], ifac[N - M]));
}
int main() {
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    fac[i] = mul(fac[i - 1], i);
    ifac[i] = qpow(fac[i], MOD - 2);
  }
  scanf("%s", s + 1);
  n = strlen(s + 1);
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '?') d++;
    if (s[i] == ')') b++;
  }
  for (int i = c + d; i >= 0; --i) {
    suf[0][i] = add(suf[0][i + 1], C(c + d - 1, i));
    suf[1][i] = add(suf[1][i + 1], C(c + d, i));
  }
  int ans = 0, lim = c + d - 1;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '(')
      a++;
    else if (s[i] == ')')
      b--;
    else if (s[i] == '?')
      d--, c++;
    if (s[i] != ')') ans = add(ans, suf[s[i] != '?'][max(0, a - b + c)]);
  }
  printf("%d\n", ans);
  return 0;
}
