#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7, p = 998244353;
char s[N];
long long fac[N], ifac[N], ch[N][2];
int n, a[N], b[N], c[N];
inline long long pows(long long u, int v) {
  long long ans = 1;
  while (v > 0) {
    if (v & 1) ans = ans * u % p;
    u = u * u % p, v = v >> 1;
  }
  return ans;
}
inline long long getans(int a, int b) {
  if (a < b) return 0;
  return fac[a] * ifac[b] % p * ifac[a - b] % p;
}
int main() {
  scanf("%s", s + 1), n = strlen(s + 1), fac[0] = ifac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % p, ifac[i] = pows(fac[i], p - 2);
  for (int i = 1; i <= n; i++) {
    a[i] = a[i - 1] + (s[i] == '(');
    b[i] = b[i - 1] + (s[i] == ')');
    c[i] = c[i - 1] + (s[i] == '?');
  }
  if (c[n] == 0)
    ch[0][1] = 1;
  else
    ch[0][0] = 1, ch[0][1] = 1;
  for (int i = 1; i <= n; i++) {
    if (c[n] >= 1)
      ch[i][0] = (ch[i - 1][0] + getans(c[n] - 1, i)) % p,
      ch[i][1] = (ch[i - 1][1] + getans(c[n], i)) % p;
    else
      ch[i][1] = (ch[i - 1][1] + getans(c[n], i)) % p;
  }
  long long val = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == ')') continue;
    int fa = a[i - 1] + 1, fb = c[i - 1], fc = b[n] - b[i], fd = c[n] - c[i];
    if (fc + fd - fa < 0) continue;
    if (fb + fd == c[n])
      val = (val + ch[fc + fd - fa][1]) % p;
    else
      val = (val + ch[fc + fd - fa][0]) % p;
  }
  cout << val << endl;
  return 0;
}
