#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
string direc = "URDL";
const long long MOD2 = (long long)998244353 * (long long)998244353;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
char s[1000035];
int fac[1000035], inv[1000035];
void initfac(int n) {
  fac[0] = inv[0] = 1;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    fac[i] = (long long)fac[i - 1] * i % 998244353;
    inv[i] = fastPow(fac[i], 998244353 - 2);
  }
}
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)fac[n] * inv[m] % 998244353 * inv[n - m] % 998244353;
}
int ps[3][1000035], psc[2][1000035];
void fmain(int tid) {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  initfac(n);
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (s[i] == '?')
      ps[0][i]++;
    else if (s[i] == '(')
      ps[1][i]++;
    else
      ps[2][i]++;
  for (int(j) = 0; (j) < (int)(3); (j)++)
    for (int(i) = 1; (i) <= (int)(n); (i)++) ps[j][i] += ps[j][i - 1];
  for (int i = 0; i <= n; i++) {
    psc[0][i] = C(ps[0][n], i);
    if (ps[0][n]) psc[1][i] = C(ps[0][n] - 1, i);
    if (i) {
      addmod(psc[0][i], psc[0][i - 1]);
      addmod(psc[1][i], psc[1][i - 1]);
    }
  }
  int ans = 0;
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (s[i] != ')') {
      int a = ps[1][i - 1];
      int b = ps[2][n] - ps[2][i];
      int d = ps[0][n] - ps[0][i];
      int cd = 0;
      if (s[i] == '?') cd = 1;
      if (b + d - a - 1 >= 0)
        addmod(ans, psc[cd][min(b + d - a - 1, ps[0][n])]);
    }
  printf("%d\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
