#include <bits/stdc++.h>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
int fact[1000010], ifact[1000010], pre[1000010], suf[1000010], sum[1000010],
    f[1000010], g[1000010];
char s[1000010];
int fpow(int a, int b) {
  int sum = 1;
  for (; b; b >>= 1) {
    if (b & 1) sum = ((long long)(sum) * (long long)(a) % 998244353);
    a = ((long long)(a) * (long long)(a) % 998244353);
  }
  return sum;
}
int C(int a, int b) {
  if (a < b || a < 0 || b < 0) return 0;
  return ((long long)(((long long)(fact[a]) * (long long)(ifact[a - b]) %
                       998244353)) *
          (long long)(ifact[b]) % 998244353);
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  fact[0] = ifact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = ((long long)(fact[i - 1]) * (long long)(i) % 998244353);
    ifact[i] = fpow(fact[i], 998244353 - 2);
  }
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + (s[i] == '?');
    pre[i] = pre[i - 1] + (s[i] == '(');
  }
  for (int i = n; i >= 1; i--) suf[i] = suf[i + 1] + (s[i] == ')');
  for (int i = 0; i <= n; i++) {
    f[i] = ((f[i - 1]) + (C(sum[n], i)) >= 998244353
                ? (f[i - 1]) + (C(sum[n], i)) - 998244353
                : (f[i - 1]) + (C(sum[n], i)));
    g[i] = ((g[i - 1]) + (C(sum[n] - 1, i)) >= 998244353
                ? (g[i - 1]) + (C(sum[n] - 1, i)) - 998244353
                : (g[i - 1]) + (C(sum[n] - 1, i)));
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int a = pre[i];
    int b = suf[i + 1];
    int c = sum[i];
    int d = sum[n] - c;
    if (s[i] == ')') {
      continue;
    } else if (s[i] == '?') {
      a++;
      if (b + d - a >= 0)
        ans = ((ans) + (g[b + d - a]) >= 998244353
                   ? (ans) + (g[b + d - a]) - 998244353
                   : (ans) + (g[b + d - a]));
    } else {
      if (b + d - a >= 0)
        ans = ((ans) + (f[b + d - a]) >= 998244353
                   ? (ans) + (f[b + d - a]) - 998244353
                   : (ans) + (f[b + d - a]));
    }
  }
  printf("%d\n", ans);
}
