#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 1e6 + 7;
int n;
char str[N];
long long fac[N], finv[N];
int pre[N], suf[N], p[N], s[N];
inline long long C(int n, int m) {
  return m <= n && m >= 0 ? fac[n] * finv[m] % mod * finv[n - m] % mod : 0;
}
inline long long qpow(long long x, int k, long long r = 1) {
  for (; k; k >>= 1, x = x * x % mod)
    if (k & 1) r = r * x % mod;
  return r;
}
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = fac[0] = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % mod;
  finv[n] = qpow(fac[n], mod - 2);
  long long ans = 0;
  for (int i = n; i; --i) finv[i - 1] = finv[i] * i % mod;
  for (int i = 1; i <= n; ++i)
    pre[i] = pre[i - 1] + (str[i] == '('), p[i] = p[i - 1] + (str[i] == '?');
  for (int i = n; i; --i)
    suf[i] = suf[i + 1] + (str[i] == ')'), s[i] = s[i + 1] + (str[i] == '?');
  for (int i = 1; i < n; ++i) {
    int l = pre[i], r = suf[i + 1], x = p[i], y = s[i + 1];
    (ans += l * C(x + y, x + l - r) + x * C(x + y - 1, y + r - l - 1)) %= mod;
  }
  return printf("%lld\n", ans), 0;
}
