#include <bits/stdc++.h>
using namespace std;
mt19937 rng(static_cast<unsigned int>(
    chrono::steady_clock::now().time_since_epoch().count()));
template <typename num_t>
inline void add_mod(num_t& a, const long long& b, const int& m) {
  a = (a + b) % m;
  if (a < 0) a += m;
}
template <typename num_t>
inline bool update_max(num_t& a, const num_t& b) {
  return a < b ? a = b, true : false;
}
template <typename num_t>
inline bool update_min(num_t& a, const num_t& b) {
  return a > b ? a = b, true : false;
}
template <typename num_t>
num_t gcd(const num_t& lhs, const num_t& rhs) {
  return !lhs ? rhs : gcd(rhs % lhs, lhs);
}
template <typename num_t>
num_t lcm(const num_t& lhs, const num_t& rhs) {
  return lhs / ::gcd(lhs, rhs) * rhs;
}
template <typename num_t>
num_t pw(num_t n, num_t k, const num_t& mod) {
  if (k == -1) k = mod - 2;
  num_t res = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) res = 1ll * res * n % mod;
    n = 1ll * n * n % mod;
  }
  return res % mod;
}
const int inf = 1e9 + 7;
const int mod = 998244353;
const long long ll_inf = (long long)inf * inf * 9 + 7;
const int maxn = 1000000 + 7;
struct InverseModule {
  static const int MOD = ::mod;
  static const int MAX_N = 1e6 + 7;
  int fact[MAX_N];
  int inv_fact[MAX_N];
  InverseModule() {
    fact[0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
      fact[i] = (long long)fact[i - 1] * i % MOD;
    }
    inv_fact[MAX_N - 1] = inverse(fact[MAX_N - 1]);
    for (int i = MAX_N - 2; i >= 0; --i) {
      inv_fact[i] = (long long)inv_fact[i + 1] * (i + 1) % MOD;
    }
  }
  int inverse(int x, int mod = MOD) {
    int r = mod, newr = x;
    int t = 0, newt = 1;
    while (newr > 0) {
      int q = r / newr;
      int tmp = newr;
      newr = r % newr;
      r = tmp;
      tmp = newt;
      newt = t - q * newt;
      t = tmp;
    }
    if (t < 0) t += mod;
    return t;
  }
  int choose(int n, int k) {
    return (long long)fact[n] * inv_fact[n - k] % MOD * inv_fact[k] % MOD;
  }
  int perm(int n, int k) { return (long long)fact[n] * inv_fact[n - k] % MOD; }
  long long pw(long long x, long long k, const long long& mod = MOD) {
    long long res = 1 % mod;
    for (; k > 0; k >>= 1) {
      if (k & 1) res = res * x % mod;
      x = x * x % mod;
    }
    return res;
  }
  pair<int, int> extended_euclid(int a, int b) {
    int s0 = 1, t0 = 0;
    int s1 = 0, t1 = 1;
    while (b > 0) {
      int q = a / b;
      int tmp = 0;
      tmp = s1;
      s1 = s0 - q * s1;
      s0 = tmp;
      tmp = t1;
      t1 = t0 - q * t1;
      t0 = tmp;
      tmp = b;
      b = a - q * b;
      a = tmp;
    }
    return {s0, t0};
  }
  int stirling_second_kind(int n, int k) {
    long long res = 0;
    for (int j = 0; j <= k; ++j) {
      long long temp = 1ll * choose(k, j) * pw(j, n);
      if ((k - j) & 1)
        res = (res - temp + MOD) % MOD;
      else
        res = (res + temp) % MOD;
    }
    return res * inv_fact[k] % MOD;
  }
} inv;
string s;
int n;
int calc[maxn];
int pre_calc[maxn];
int f_left[maxn];
int f_right[maxn];
long long sum[2][maxn];
void solve() {
  cin >> s;
  n = (int)(s).size();
  int num_question_mark = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '?') {
      f_left[i] = 1;
    }
    if (i) f_left[i] += f_left[i - 1];
    if (s[i] == '(') calc[i] = 1;
    if (i) calc[i] += calc[i - 1];
  }
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == ')') pre_calc[i] = 1;
    pre_calc[i] += pre_calc[i + 1];
    if (s[i] == '?') f_right[i] = 1;
    f_right[i] += f_right[i + 1];
  }
  num_question_mark = f_left[n - 1];
  for (int i = 0; i < maxn; ++i) {
    if (i <= num_question_mark) sum[1][i] = inv.choose(num_question_mark, i);
    if (i < num_question_mark) sum[0][i] = inv.choose(num_question_mark - 1, i);
    if (i) {
      for (int c = (0), _b = (2); c < _b; ++c)
        add_mod(sum[c][i], sum[c][i - 1], mod);
    }
  }
  cerr << "num_question_mark"
       << ": " << (num_question_mark) << '\n';
  ;
  auto get_cost = [&](char c, int u, int v) -> long long {
    if (v < 0) return 0;
    int idx = (c != '?');
    long long res = sum[idx][v];
    if (u) add_mod(res, -sum[idx][u - 1], mod);
    return res;
  };
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '?' || s[i] == '(') {
      int lhs = i > 0 ? calc[i - 1] : 0;
      int prev_mask = i > 0 ? f_left[i - 1] : 0;
      add_mod(res,
              get_cost(s[i], 0, pre_calc[i + 1] + f_right[i + 1] - lhs - 1),
              mod);
    }
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test) cin >> test;
  for (int i = 0; i < test; ++i) {
    solve();
  }
}
