#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const long long mod = 998244353;
char str[1000010];
long long n, fac[2000010], inv[2000010], pre[1000010], suf[1000010],
    pre1[1000010], suf1[1000010];
long long ans;
inline long long C(long long n, long long m) {
  if (n < 0 || m < 0 || m > n) return 0;
  return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
inline long long qpow(long long x, long long k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return res;
}
signed main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  fac[0] = inv[0] = 1;
  for (long long i = 1; i <= 2 * n; i++) fac[i] = fac[i - 1] * i % mod;
  inv[2 * n] = qpow(fac[2 * n], mod - 2);
  for (long long i = 2 * n - 1; i >= 1; i--)
    inv[i] = inv[i + 1] * (i + 1) % mod;
  for (long long i = 1; i <= n; i++)
    pre[i] = pre[i - 1] + (str[i] == '('),
    pre1[i] = pre1[i - 1] + (str[i] == '?');
  for (long long i = n; i >= 1; i--)
    suf[i] = suf[i + 1] + (str[i] == ')'),
    suf1[i] = suf1[i + 1] + (str[i] == '?');
  for (long long i = 1; i < n; i++) {
    ans = ans +
          pre[i] * C(pre1[i] + suf1[i + 1], suf1[i + 1] + suf[i + 1] - pre[i]) %
              mod;
    ans = ans +
          pre1[i] *
              C(pre1[i] + suf1[i + 1] - 1, pre1[i] + pre[i] - suf[i + 1]) % mod;
    ans %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}
