#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = v * 10 + c - '0';
    c = getchar();
  }
  return v * f;
}
const int Maxn = 3000005;
const long long mod = 998244353;
long long fact[Maxn], ivf[Maxn];
long long qp(long long x, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = ret * x % mod;
    p >>= 1;
    x = x * x % mod;
  }
  return ret;
}
long long inv(long long x) { return qp(x, mod - 2); }
void _init() {
  fact[0] = 1;
  for (int i = 1; i < Maxn; i++) {
    fact[i] = fact[i - 1] * i % mod;
  }
  ivf[Maxn - 1] = inv(fact[Maxn - 1]);
  for (int i = Maxn - 2; i >= 0; i--) {
    ivf[i] = ivf[i + 1] * (i + 1) % mod;
  }
}
long long C(long long x, long long y) {
  if (y < 0 || y > x) return 0;
  return fact[x] * ivf[y] % mod * ivf[x - y] % mod;
}
char s[Maxn];
int main() {
  _init();
  scanf("%s", s);
  int n = strlen(s);
  int tl = 0, tr = 0, tq = 0;
  for (int i = 0; i < n; i++) {
    tl += (s[i] == '(');
    tr += (s[i] == ')');
    tq += (s[i] == '?');
  }
  int cl = 0, cr = 0, cq = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cl += (s[i] == '(');
    cr += (s[i] == ')');
    cq += (s[i] == '?');
    int a = cq, b = tq - cq, x = cl, y = tr - cr;
    ans +=
        1ll * x * C(a + b, b - x + y) + 1ll * a * C(a + b - 1, b - x + y - 1);
    ans %= mod;
  }
  printf("%lld\n", ans);
}
