#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(int x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const int maxn = 1e6 + 10;
const int inf = 1e9;
const double eps = 1e-8;
const int mod = 998244353;
char s[maxn];
int n, fac[maxn], ifac[maxn], inv[maxn], a[maxn], b[maxn], f[maxn], r[maxn],
    t[maxn];
void gen() {
  fac[0] = ifac[0] = inv[0] = inv[1] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = 1ll * fac[i - 1] * i % mod;
    if (i > 1) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
  }
}
int c(int x, int y) { return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod; }
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  gen();
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1] + (s[i] == '(');
    b[i] = b[i - 1] + (s[i] == ')');
    f[i] = f[i - 1] + (s[i] == '?');
  }
  for (int i = f[n]; ~i; i--) r[i] = (r[i + 1] + c(f[n], i)) % mod;
  for (int i = f[n] - 1; ~i; i--) t[i] = (t[i + 1] + c(f[n] - 1, i)) % mod;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = max(0, -(b[n] - b[i]) + a[i] + f[i]);
    if (s[i] == '?')
      ans = (ans + t[x]) % mod;
    else if (s[i] == '(')
      ans = (ans + r[x]) % mod;
  }
  write(ans);
  return 0;
}
