#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long N = 1e6 + 5;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
long long n;
char c[N];
long long pre1[N], pre2[N], suf1[N], suf2[N];
long long pre[N], ni[N];
inline long long power(long long x, long long y) {
  long long ans = 1;
  for (; y; y >>= 1) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
  }
  return ans;
}
inline void prework() {
  pre[0] = ni[0] = 1;
  for (long long i = 1; i <= n; i++) pre[i] = pre[i - 1] * i % mod;
  ni[n] = power(pre[n], mod - 2);
  for (long long i = n - 1; i >= 1; i--) ni[i] = ni[i + 1] * (i + 1) % mod;
  for (long long i = 1; i <= n; i++) pre1[i] = pre1[i - 1] + (c[i] == '?');
  for (long long i = 1; i <= n; i++) pre2[i] = pre2[i - 1] + (c[i] == '(');
  for (long long i = n; i >= 1; i--) suf1[i] = suf1[i + 1] + (c[i] == '?');
  for (long long i = n; i >= 1; i--) suf2[i] = suf2[i + 1] + (c[i] == ')');
}
inline long long C(long long n, long long m) {
  if (n < m) return 0;
  return pre[n] * ni[m] % mod * ni[n - m] % mod;
}
signed main() {
  long long Ans = 0;
  scanf("%s", c + 1);
  n = strlen(c + 1);
  prework();
  for (long long i = 1; i <= n; i++) {
    long long l1 = pre1[i], l2 = pre2[i];
    long long r1 = suf1[i + 1], r2 = suf2[i + 1];
    long long d = r1 + r2 - l2;
    if (d < 0) continue;
    if (!d)
      Ans = (Ans + l2) % mod;
    else
      Ans =
          (Ans + l2 * C(l1 + r1, d) % mod + l1 * C(l1 + r1 - 1, d - 1) % mod) %
          mod;
  }
  printf("%lld\n", Ans);
  return 0;
}
