#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10, MAXM = 4e4 + 10;
const int INF = INT_MAX, MOD = 1e9 + 7, mod = 998244353;
const long long llINF = ~(1ll << 63);
long long getinv(long long x) {
  long long ans = 1, v = mod - 2;
  x %= mod;
  while (v) {
    if (v & 1) (ans *= x) %= mod;
    (x *= x) %= mod;
    v >>= 1;
  }
  return ans;
}
string s;
int a, b, c, d;
map<int, vector<int> > dps;
int calc() {
  long long x = min(b + d - a, c + d), t = 0, w = 1;
  if (x < 0) return 0;
  int k = c + d;
  if (dps.count(k)) return dps[k][x];
  vector<int> &dp = dps[k];
  dp.resize(k + 1);
  for (int i = 0; i <= k; i++) {
    (t += w) %= mod;
    dp[i] = t;
    (w *= ((c + d - i) * getinv(i + 1)) % mod) %= mod;
  }
  return dp[x];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  for (auto ch : s)
    if (ch == ')')
      b++;
    else if (ch == '?')
      d++;
  long long ans = 0;
  for (auto ch : s) {
    if (ch == '(') a++, (ans += calc()) %= mod;
    if (ch == ')') b--;
    if (ch == '?') {
      a++;
      d--;
      (ans += calc()) %= mod;
      c++;
      a--;
    }
  }
  cout << ans;
  return 0;
}
