#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T>
void read(T &x) {
  x = 0;
  int c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
T _max(T a, T b) {
  return b < a ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 2000005;
const int mod = 998244353;
void add(int &a, int b) {
  a += b;
  (a >= mod) && (a -= mod);
}
void sub(int &a, int b) {
  a -= b;
  (a < 0) && (a += mod);
}
void mul(int &a, int b) { a = (long long)a * b % mod; }
int Add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}
int Sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}
int Mul(int a, int b) { return (long long)a * b % mod; }
int qpow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return ans;
}
int Inv(int a) { return qpow(a, mod - 2); }
char s[N];
int n;
int fac[N], ifac[N];
int sn[N], sl[N], sr[N];
int f[N], g[N];
int binom(int n, int m) {
  return n < 0 || m < 0 || n < m ? 0 : Mul(fac[n], Mul(ifac[m], ifac[n - m]));
}
void prepare(int n) {
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = Mul(fac[i - 1], i);
  ifac[n] = qpow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; --i) ifac[i] = Mul(ifac[i + 1], i + 1);
}
void calc(int p, int *a) {
  if (p < 0) return;
  for (int i = 0; i <= p; ++i) a[i] = binom(p, i);
  for (int i = 1; i <= p; ++i) add(a[i], a[i - 1]);
}
void init() {
  prepare(2000000);
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    sl[i] = sl[i - 1] + (s[i] == '(');
    sr[i] = sr[i - 1] + (s[i] == ')');
    sn[i] = sn[i - 1] + (s[i] == '?');
  }
  calc(sn[n], f);
  calc(sn[n] - 1, g);
}
void solve() {
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (s[i] != ')') {
      int a = sl[i - 1], b = sn[i - 1], c = sr[n] - sr[i], d = sn[n] - sn[i];
      int lim = _min(c + d - a - 1, b + d);
      if (lim >= 0) {
        if (b + d == sn[n])
          add(ans, f[lim]);
        else
          add(ans, g[lim]);
      }
    }
  printf("%d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
