#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, mod = 998244353;
long long n, in[N], p[N], s[2][N];
char a[N];
long long qpow(long long x, long long y) {
  long long t = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long C(long long x, long long y) {
  return x < y ? 0 : p[x] * in[y] % mod * in[x - y] % mod;
}
void prework() {
  p[0] = 1;
  for (long long i = 1; i <= n; ++i) p[i] = p[i - 1] * i % mod;
  in[n] = qpow(p[n], mod - 2);
  for (long long i = n; i >= 1; --i) in[i - 1] = in[i] * i % mod;
}
long long cl[N], cr[N], sl[N], sr[N];
signed main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  prework();
  for (long long i = 1; i <= n; ++i)
    cl[i] = cl[i - 1] + (a[i] == '('), sl[i] = sl[i - 1] + (a[i] == '?');
  for (long long i = n; i >= 1; --i)
    cr[i] = cr[i + 1] + (a[i] == ')'), sr[i] = sr[i + 1] + (a[i] == '?');
  s[0][0] = s[1][0] = 1;
  long long res = 0;
  for (long long i = 1; i <= n; ++i) {
    s[1][i] = (s[1][i - 1] + C(sl[n] - 1, i)) % mod;
    s[0][i] = (s[0][i - 1] + C(sl[n], i)) % mod;
  }
  for (long long i = 1; i <= n; ++i)
    if (cl[i - 1] < cr[i + 1] + sr[i + 1] && a[i] != ')')
      (res += s[a[i] == '?'][cr[i + 1] + sr[i + 1] - cl[i - 1] - 1]) %= mod;
  printf("%lld\n", res);
}
