#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
struct modint {
  int x;
  modint(int o = 0) { x = o; }
  modint &operator=(int o) { return x = o, *this; }
  modint &operator+=(modint o) {
    return x = x + o.x >= 998244353 ? x + o.x - 998244353 : x + o.x, *this;
  }
  modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + 998244353 : x - o.x, *this;
  }
  modint &operator*=(modint o) { return x = 1ll * x * o.x % 998244353, *this; }
  modint &operator^=(int b) {
    modint a = *this, c = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) c *= a;
    return x = c.x, *this;
  }
  modint &operator/=(modint o) { return *this *= o ^= 998244353 - 2; }
  modint &operator+=(int o) {
    return x = x + o >= 998244353 ? x + o - 998244353 : x + o, *this;
  }
  modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + 998244353 : x - o, *this;
  }
  modint &operator*=(int o) { return x = 1ll * x * o % 998244353, *this; }
  modint &operator/=(int o) { return *this *= ((modint(o)) ^= 998244353 - 2); }
  template <class I>
  friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  friend modint operator*(modint a, I b) {
    return a *= b;
  }
  template <class I>
  friend modint operator/(modint a, I b) {
    return a /= b;
  }
  friend modint operator^(modint a, int b) { return a ^= b; }
  friend bool operator==(modint a, int b) { return a.x == b; }
  friend bool operator!=(modint a, int b) { return a.x != b; }
  bool operator!() { return !x; }
  modint operator-() { return x ? 998244353 - x : 0; }
};
inline modint qpow(modint a, int b) { return a ^ b; }
int n, cnt;
modint c1[1000005], sc1[1000005], c2[1000005], sc2[1000005], res;
char s[1000005];
int pre[1000005], suf[1000005], a[1000005], b[1000005];
signed main() {
  scanf("%s", s + 1), n = strlen(s + 1);
  for (register int i = (1); i <= (n); ++i)
    pre[i] = pre[i - 1] + (s[i] == '?'), a[i] = a[i - 1] + (s[i] == '(');
  for (register int i = (n); i >= (1); --i)
    suf[i] = suf[i + 1] + (s[i] == '?'), b[i] = b[i + 1] + (s[i] == ')');
  cnt = pre[n];
  c1[0] = c2[0] = sc1[0] = sc2[0] = 1;
  for (register int i = (1); i <= (cnt); ++i) {
    c1[i] = c1[i - 1] * (cnt - i + 1) / i;
    c2[i] = c2[i - 1] * (cnt - i) / i;
    sc1[i] = sc1[i - 1] + c1[i], sc2[i] = sc2[i - 1] + c2[i];
  }
  for (register int i = (1); i <= (n); ++i) {
    int mx = a[i - 1] - b[i + 1] + pre[i - 1] - 1;
    if (mx >= 0) {
      if (s[i] == ')') res += sc1[min(mx, cnt)];
      if (s[i] == '?') res += sc2[min(mx, cnt - 1)];
    }
  }
  cout << res.x;
  return 0;
}
