#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100, mod = (int)998244353;
int n, q[N], o[N], c[N];
int f[N], C[2][N], inv[N];
inline int ncr(int a, int b) {
  if (a - b < 0) return 0;
  return (int)(((f[a] * 1ll * inv[b]) % mod * 1ll * inv[a - b]) % mod);
}
inline void add(int &a, int b) {
  a = a + b;
  if (a >= mod) a -= mod;
}
int powmod(int a, int b) {
  if (b == 0) return 1;
  int x = powmod(a, b / 2);
  x = (int)((x * 1ll * x) % mod);
  if (b % 2 == 0)
    return x;
  else
    return (int)((x * 1ll * a) % mod);
}
int main(int argc, const char *argv[]) {
  string s;
  cin >> s;
  n = (int)s.length();
  s = "#" + s;
  for (int i = 1; i <= n; ++i) {
    q[i] = q[i - 1] + (s[i] == '?');
    o[i] = o[i - 1] + (s[i] == '(');
    c[i] = c[i - 1] + (s[i] == ')');
  }
  f[0] = inv[0] = 1;
  for (int i = 1; i < N; ++i) f[i] = (f[i - 1] * 1ll * i) % mod;
  for (int j = 1; j < N; ++j) inv[j] = powmod(f[j], mod - 2);
  C[0][0] = C[1][0] = 1;
  for (int i = 1; i <= n; ++i) {
    C[0][i] = ncr(q[n], i);
    C[1][i] = ncr(q[n] - 1, i);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 2; ++j) add(C[j][i], C[j][i - 1]);
  }
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == ')') continue;
    int cafter = c[n] - c[i];
    int qafter = q[n] - q[i];
    int onow = o[i - 1], qnow = q[i - 1];
    if (cafter + qafter - onow - 1 < 0) continue;
    if (s[i] == '?')
      add(res, C[1][cafter - onow + qafter - 1]);
    else
      add(res, C[0][cafter - onow + qafter - 1]);
  }
  cout << res << "\n";
  return 0;
}
