#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, P = 998244353;
map<int, int[N]> dp;
int main() {
  auto inv = [&](int a) {
    int res = 1, b = P - 2;
    for (; b; b >>= 1) {
      if (b & 1) res = 1ll * res * a % P;
      a = 1ll * a * a % P;
    }
    return res;
  };
  string s;
  cin >> s;
  int preq = 0, sufq = 0, pret = 0, suft = 0;
  for (auto ch : s) {
    if (ch == '?')
      sufq++;
    else if (ch == ')')
      suft++;
  }
  auto cal = [&]() {
    int tot = sufq + preq;
    int ed = sufq + suft - pret;
    if (ed < 0) return 0;
    if (ed > tot) ed = tot;
    if (dp.count(tot)) return dp[tot][ed];
    dp[tot][0] = 1;
    int w = 1;
    for (int i = 1; i <= ed; i++) {
      w = 1ll * w * (tot - i + 1) % P;
      w = 1ll * w * inv(i) % P;
      dp[tot][i] = dp[tot][i - 1] + w;
      if (dp[tot][i] >= P) dp[tot][i] -= P;
    }
    return dp[tot][ed];
  };
  int ans = 0;
  for (auto ch : s) {
    if (ch == '(') {
      pret++;
      ans += cal();
    } else if (ch == ')') {
      suft--;
    } else {
      sufq--;
      pret++;
      ans += cal();
      preq++, pret--;
    }
    if (ans >= P) ans -= P;
  }
  cout << ans;
}
