#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 100, mod = 998244353;
int qpow(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % mod;
    x = 1ll * x * x % mod, y >>= 1;
  }
  return res;
}
int n, m, fac[N], inv[N], pre[N], suf[N], ans;
char str[N];
int C(int x, int y) {
  if (x < y || x < 0 || y < 0) return 0;
  return 1ll * fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  fac[0] = 1;
  for (int i = 1; i <= 2 * n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
  inv[2 * n] = qpow(fac[2 * n], mod - 2);
  for (int i = 2 * n - 1; ~i; --i) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
  for (int i = 1; i <= n; ++i) m += (str[i] == '?');
  for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + (str[i] == '(');
  for (int i = n; i >= 1; --i) suf[i] = suf[i + 1] + (str[i] == ')');
  for (int i = 1, x = 0, y = m; i < n; ++i) {
    if (str[i] == '?') ++x, --y;
    int b = max(pre[i], suf[i + 1]), a = b - min(pre[i], suf[i + 1]);
    if (b == pre[i])
      ans = (ans + 1ll * b * C(x + y, x + a) % mod +
             1ll * x * C(x + y - 1, y - a - 1) % mod) %
            mod;
    else
      ans = (ans + 1ll * b * C(x + y, y + a) % mod +
             1ll * y * C(x + y - 1, x - a - 1) % mod) %
            mod;
  }
  cout << ans;
  return 0;
}
