#include <bits/stdc++.h>
using namespace std;
using LL = long long;
namespace _buff {
const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
  if (ib == ie) {
    ib = ibuf;
    ie = ibuf + fread(ibuf, 1, BUFF, stdin);
  }
  return ib == ie ? -1 : *ib++;
}
}  // namespace _buff
LL read() {
  using namespace _buff;
  LL ret = 0;
  bool pos = true;
  char c = getc();
  for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    assert(~c);
  }
  if (c == '-') {
    pos = false;
    c = getc();
  }
  for (; c >= '0' && c <= '9'; c = getc()) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
  }
  return pos ? ret : -ret;
}
const size_t N = 1e6 + 5;
const int MOD = 998244353;
void iadd(int &dp, const int &val) {
  dp += val;
  if (dp >= MOD) {
    dp -= MOD;
  }
}
void ladd(int &dp, const LL &val) { dp = (dp + val) % MOD; }
int qpow(int base, int e) {
  int ret = 1;
  for (; e; e >>= 1) {
    if (e & 1) {
      ret = (LL)ret * base % MOD;
    }
    base = (LL)base * base % MOD;
  }
  return ret;
}
char s[N];
int fac[N], inv[N], pw2[N];
int sum[2][N];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int ques = count(s, s + n, '?');
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fac[i] = (LL)fac[i - 1] * i % MOD;
  }
  inv[n] = qpow(fac[n], MOD - 2);
  for (int i = n; i >= 1; --i) {
    inv[i - 1] = (LL)inv[i] * i % MOD;
  }
  pw2[0] = 1;
  for (int i = 1; i <= n; ++i) {
    pw2[i] = pw2[i - 1];
    iadd(pw2[i], pw2[i]);
  }
  for (int j = 0; j < 2; ++j) {
    int cur = 0;
    for (int i = 0; i <= ques; ++i) {
      if (i <= ques - j) {
        ladd(cur, (LL)fac[ques - j] * inv[i] % MOD * inv[ques - j - i]);
      }
      sum[j][i] = cur;
    }
  }
  auto get_sum = [&](int k, int i) {
    return i >= 0 ? sum[k][min(i, ques)] : 0;
  };
  int ans = 0;
  int a = 0, b = count(s, s + n, ')');
  int c = 0, d = ques;
  for (int i = 0; i < n; ++i) {
    int tmp = MOD - ans;
    if (s[i] != ')') {
      ++a;
    } else {
      --b;
    }
    if (s[i] == '?') {
      --d;
    }
    if (s[i] != ')') {
      iadd(ans, get_sum(ques - c - d, b + d - a));
    }
    if (s[i] == '?') {
      --a;
      ++c;
    }
    iadd(tmp, ans);
  }
  printf("%d\n", ans);
  return 0;
}
