#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000010;
const int mod = 998244353;
const int inf = 2147483647;
const double pi = acos(-1.0);
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
void upd(int& x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
char s[Maxn];
int n;
int fac[Maxn], inv[Maxn], fin[Maxn], f[Maxn], g[Maxn];
void init() {
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = (long long)fac[i - 1] * i % mod;
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; i++)
    inv[i] = (long long)(mod - mod / i) * inv[mod % i] % mod;
  fin[0] = 1;
  for (int i = 1; i <= n; i++) fin[i] = (long long)fin[i - 1] * inv[i] % mod;
}
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)fac[n] * fin[m] % mod * fin[n - m] % mod;
}
int a[Maxn], b[Maxn], c[Maxn], d[Maxn];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init();
  a[0] = c[0] = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1], c[i] = c[i - 1];
    if (s[i] == '(') a[i]++;
    if (s[i] == '?') c[i]++;
  }
  b[n + 1] = d[n + 1] = 0;
  for (int i = n; i; i--) {
    b[i] = b[i + 1], d[i] = d[i + 1];
    if (s[i] == ')') b[i]++;
    if (s[i] == '?') d[i]++;
  }
  f[0] = g[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1], g[i] = g[i - 1];
    upd(f[i], C(c[n], i));
    upd(g[i], C(c[n] - 1, i));
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (s[i] != ')' && b[i + 1] - a[i - 1] + d[i + 1] - 1 >= 0) {
      if (s[i] == '(')
        upd(ans, f[b[i + 1] - a[i - 1] + d[i + 1] - 1]);
      else
        upd(ans, g[b[i + 1] - a[i - 1] + d[i + 1] - 1]);
    }
  printf("%d", ans);
}
