#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
const int MOD = 998244353;
template <typename T>
inline void read(T &AKNOI) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  AKNOI = flag * x;
}
namespace ModCalculator {
inline void Inc(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
inline void Dec(int &x, int y) {
  x -= y;
  if (x < 0) x += MOD;
}
inline int Add(int x, int y) {
  Inc(x, y);
  return x;
}
inline int Sub(int x, int y) {
  Dec(x, y);
  return x;
}
inline int Mul(int x, int y) { return 1LL * x * y % MOD; }
}  // namespace ModCalculator
using namespace ModCalculator;
inline int ksm(int x, int k) {
  int ret = 1;
  while (k) {
    if (k & 1) ret = Mul(ret, x);
    x = Mul(x, x);
    k >>= 1;
  }
  return ret;
}
char s[MAXN];
int n, a, b, c, d, cnt;
int fac[MAXN], finv[MAXN], sum[2][MAXN];
inline int C(int x, int y) { return Mul(fac[x], Mul(finv[y], finv[x - y])); }
void init() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == ')') ++c;
    if (s[i] == '?') ++d;
  }
  cnt = d;
  fac[0] = 1;
  for (int i = 1; i <= d; ++i) {
    fac[i] = Mul(fac[i - 1], i);
  }
  finv[d] = ksm(fac[d], MOD - 2);
  for (int i = d - 1; i >= 0; --i) {
    finv[i] = Mul(finv[i + 1], i + 1);
  }
  sum[0][0] = sum[1][0] = 1;
  for (int i = 1; i <= n; ++i) {
    sum[0][i] = Add(sum[0][i - 1], C(d - 1, i));
    sum[1][i] = Add(sum[1][i - 1], C(d, i));
  }
}
inline int Calc() {
  int _cnt = b + d;
  int lim = min(_cnt, c + d - a);
  if (lim < 0) return 0;
  return sum[_cnt == cnt][lim];
}
void solve() {
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '(') ++a;
    if (s[i] == ')') --c;
    if (s[i] == '?') ++b, --d;
    if (s[i] == '(') {
      Inc(ans, Calc());
    } else if (s[i] == '?') {
      ++a;
      --b;
      Inc(ans, Calc());
      --a;
      ++b;
    }
  }
  printf("%d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
