#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10, mod = 998244353;
long long n, s1, s2, ans;
char s[N];
long long fac[N], ifac[N], sum1[N], sum2[N], a[N], b[N], c[N], d[N];
inline long long pw(long long x, long long y) {
  long long res = 1;
  for (; y; x = x * x % mod, y >>= 1)
    if (y & 1) res = res * x % mod;
  return res;
}
void init() {
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  ifac[n] = pw(fac[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--) ifac[i] = ifac[i + 1] * (i + 1) % mod;
}
long long C(long long x, long long y) {
  if (x < 0 || y < 0) return 0;
  return fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init();
  for (long long i = 1; i <= n; i++) s1 += (s[i] == '?');
  s2 = s1 - 1;
  sum1[0] = C(s1, 0);
  for (long long i = 1; i <= s1; i++) sum1[i] = (sum1[i - 1] + C(s1, i)) % mod;
  for (long long i = s1 + 1; i <= n; i++) sum1[i] = sum1[i - 1];
  if (s2 >= 0) {
    sum2[0] = C(s2, 0);
    for (long long i = 1; i <= s2; i++)
      sum2[i] = (sum2[i - 1] + C(s2, i)) % mod;
    for (long long i = s2 + 1; i <= n; i++) sum2[i] = sum2[i - 1];
  }
  for (long long i = 1; i <= n; i++)
    a[i] = a[i - 1] + (s[i] == '('), b[i] = b[i - 1] + (s[i] == '?');
  for (long long i = n; i >= 1; i--)
    c[i] = c[i + 1] + (s[i] == ')'), d[i] = d[i + 1] + (s[i] == '?');
  for (long long i = 1; i <= n; i++) {
    if (s[i] == ')') {
      long long tmp = a[i - 1] + b[i - 1] - c[i + 1] - 1;
      if (tmp >= 0) ans = (ans + sum1[tmp]) % mod;
    } else if (s[i] == '?') {
      long long tmp = a[i - 1] + b[i - 1] - c[i + 1] - 1;
      if (s2 >= 0 && tmp >= 0) ans = (ans + sum2[tmp]) % mod;
    }
  }
  printf("%lld", ans);
}
