#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000100;
const long long mod = 998244353;
int powmod(int a, long long x) {
  int res = 1;
  while (x) {
    if (x & 1) {
      res = ((long long)(res)*a) % mod;
    }
    a = ((long long)(a)*a) % mod;
    x >>= 1;
  }
  return res;
}
int modinv(long long x) { return powmod(x, mod - 2); }
long long adj(long long val) {
  if (val >= 0 && val < mod) {
    return val;
  }
  val %= mod;
  if (val >= 0) {
    return val;
  }
  if (val < 0) {
    val += mod;
    return val;
  }
}
int sums[maxN];
long long minv[maxN];
int get_cnt(int l, int r) {
  if (r < 0) {
    return 0;
  }
  int res1 = sums[r];
  int res2 = 0;
  if (l - 1 >= 0) {
    res2 = sums[l - 1];
  }
  return res1 - res2;
}
vector<long long> cnk[2];
int val[2];
void fillcnk(int n, vector<long long>& res) {
  if (n < 0) {
    return;
  }
  res.resize(n + 1);
  long long num = 1;
  long long denom = 1;
  res[0] = 1;
  for (int i = 1; i <= n; ++i) {
    num *= (long long)(n - i + 1);
    num %= mod;
    denom *= minv[i];
    denom %= mod;
    res[i] = num * denom;
    res[i] %= mod;
  }
  for (int i = 1; i <= n; ++i) {
    res[i] += res[i - 1];
    res[i] %= mod;
  }
}
void solve() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '?') {
      sums[i] += 1;
    }
    if (i > 0) {
      sums[i] += sums[i - 1];
    }
  }
  for (int i = 0; i <= s.size(); ++i) {
    minv[i] = modinv(i);
  }
  long long cl = 0, cr = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == ')') {
      ++cr;
    }
  }
  int n = s.length();
  int tot = get_cnt(0, n - 1);
  val[0] = tot;
  fillcnk(tot, cnk[0]);
  val[1] = tot - 1;
  fillcnk(tot - 1, cnk[1]);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == ')') {
      --cr;
    } else if (s[i] == '(' || s[i] == '?') {
      int a = cl, b = cr;
      int c = get_cnt(0, i - 1);
      int d = get_cnt(i + 1, n - 1);
      int lim = min(b + d - a - 1, c + d);
      if (lim >= 0) {
        int idx = 0;
        if (c + d == val[1]) {
          idx = 1;
        }
        ans += cnk[idx][lim];
        if (ans >= mod) {
          ans -= mod;
        }
      }
      if (s[i] == '(') {
        ++cl;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  for (int tt = 0; tt < t; ++tt) {
    solve();
  }
  return 0;
}
