#include <bits/stdc++.h>
using namespace std;
mt19937_64 rnd;
const long long maxn = 1e6 + 10;
const long long mod = 998244353;
const long long base = 500;
long long gt[maxn];
long long gtv[maxn];
long long mu(long long a, long long n) {
  if (n == 0) return 1;
  if (n == 1) return a;
  long long t = mu(a, n / 2);
  if (n % 2 == 0) return (t * t) % mod;
  return ((t * t) % mod * a) % mod;
}
void setup() {
  gt[0] = 1;
  for (int i = 1; i < maxn; i++) {
    gt[i] = (gt[i - 1] * i) % mod;
  }
  gtv[maxn - 1] = mu(gt[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; i--) {
    gtv[i] = (gtv[i + 1] * (i + 1)) % mod;
  }
}
long long nck(long long n, long long k) {
  if (n < k) return 0;
  return ((gt[n] * gtv[k]) % mod * gtv[n - k]) % mod;
}
long long f[maxn];
long long f1[maxn];
long long f2[maxn];
long long dp[maxn][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (fopen("t.inp", "r")) {
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  setup();
  string s;
  cin >> s;
  long long n = s.length();
  s = " " + s;
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1] + (s[i] == '(');
    f1[i] = f1[i - 1] + (s[i] == '?');
    f2[i] = f2[i - 1] + (s[i] == ')');
  }
  long long all = f1[n];
  for (int j = 0; j <= min(all, 1ll); j++) {
    for (int i = 0; i <= n; i++) {
      dp[i][j] = ((i > 0 ? dp[i - 1][j] : 0) + nck(all - j, i)) % mod;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == ')') continue;
    long long a = f[i - 1];
    long long b = f2[n] - f2[i];
    long long c = f1[i - 1];
    long long d = f1[n] - f1[i];
    if (d + b - a > 0) ans = (ans + dp[d + b - a - 1][s[i] == '?']) % mod;
  }
  cout << ans;
}
