#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void cmin(T &a, T b) {
  ((a > b) && (a = b));
}
template <class T>
inline void cmax(T &a, T b) {
  ((a < b) && (a = b));
}
char IO;
template <class T = int>
T rd() {
  T s = 0;
  int f = 0;
  while (!isdigit(IO = getchar())) f |= IO == '-';
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 1e6 + 10, P = 998244353;
int n;
char s[N];
int c1[N], c2[N], c3[N];
int I[N], J[N];
long long qpow(long long x, long long k = P - 2) {
  long long res = 1;
  for (; k; k >>= 1, x = x * x % P)
    if (k & 1) res = res * x % P;
  return res;
}
long long C(int n, int m) {
  return n < 0 || m < 0 || n < m ? 0 : 1ll * J[n] * I[m] % P * I[n - m] % P;
}
int a, b, c, d, res;
int S(int n, int m) {
  if (m >= n) return qpow(2, n);
  if (m < 0) return 0;
  static int p1 = 0, p2 = 0, res = 1;
  while (p2 < m) res = (res + C(p1, ++p2)) % P;
  while (p2 > m) res = (res - C(p1, p2--) + P) % P;
  while (p1 < n) res = (res * 2ll - C(p1++, p2) + P) % P;
  while (p1 > n) res = 1ll * (res + C(--p1, p2)) * (P + 1) / 2 % P;
  return res;
}
int Calc(int a, int b, int c, int d) {
  c -= a + b;
  c = max(0, -c + 1);
  return (S(b + d, b + d) - S(b + d, c - 1) + P) % P;
}
int main() {
  for (int i = *J = 1, iend = N - 1; i <= iend; ++i)
    J[i] = 1ll * J[i - 1] * i % P;
  I[N - 1] = qpow(J[N - 1]);
  for (int i = N - 1, iend = 1; i >= iend; --i) I[i - 1] = 1ll * I[i] * i % P;
  scanf("%s", s + 1), n = strlen(s + 1);
  for (int i = 1, iend = n; i <= iend; ++i) c += s[i] == ')', d += s[i] == '?';
  int ans = 0;
  for (int i = 1, iend = n - 1; i <= iend; ++i) {
    c -= s[i] == ')', d -= s[i] == '?';
    if (s[i] == '(' || s[i] == '?')
      ans += Calc(a, b, c, d), ((ans >= P) && (ans -= P));
    a += s[i] == '(', b += s[i] == '?';
  }
  printf("%d\n", ans);
}
