#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 500, mod = 998244353;
int fac[N], ifac[N], inv[N], suf[N], sl[N], sr[N];
char st[N];
void make(int n) {
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
  ifac[0] = ifac[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= n; i++)
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod,
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
}
int C(int n, int m) {
  if (n < 0 || m < 0 || m > n) return 0;
  return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main() {
  scanf("%s", st + 1);
  int n = strlen(st + 1);
  make(n);
  int s = 0;
  for (int i = 1; i <= n; i++) s += (st[i] == '?');
  for (int i = n; i >= 1; i--) suf[i] = suf[i + 1] + (st[i] == '?');
  for (int i = 1; i <= n; i++) sl[i] = sl[i - 1] + (st[i] == '(');
  for (int i = n; i >= 1; i--) sr[i] = sr[i + 1] + (st[i] == ')');
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    int y = suf[i + 1], t = sr[i + 1] - sl[i];
    ans =
        (ans + 1ll * sr[i + 1] * C(s, t + y) + 1ll * y * C(s - 1, t + y)) % mod;
  }
  cout << (ans % mod + mod) % mod << endl;
}
