#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int F[1000001], Finv[1000001], S1[1000002], S2[1000002], C1[1000001],
    C2[1000001], C3[1000001];
int mul(int a, int b) { return 1LL * a * b % MOD; }
int fast_pow(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) ret = mul(ret, a);
    a = mul(a, a);
  }
  return ret;
}
int nCr(int n, int r) {
  if (r < 0 || n < r) return 0;
  return mul(F[n], mul(Finv[r], Finv[n - r]));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ((void)0);
  ((void)0);
  ((void)0);
  int N, ans = 0, t;
  string s;
  cin >> s;
  N = s.size();
  for (int i = 0; i < N; i++) {
    C1[i + 1] = C1[i] + (s[i] == '(');
    C2[i + 1] = C2[i] + (s[i] == ')');
    C3[i + 1] = C3[i] + (s[i] == '?');
  }
  F[0] = Finv[0] = 1;
  for (int i = 1; i <= 1000000; i++) F[i] = mul(F[i - 1], i);
  Finv[1000000] = 490058372;
  for (int i = 1000000; --i;) Finv[i] = mul(i + 1, Finv[i + 1]);
  for (int i = t = C3[N]; i >= 0; i--) {
    S1[i] = (S1[i + 1] + nCr(t, i)) % MOD;
    S2[i] = (S2[i + 1] + nCr(t - 1, i)) % MOD;
  }
  for (int i = 1; i <= N; i++) {
    t = max(C1[i] - (C2[N] - C2[i]) + C3[i], 0);
    if (s[i - 1] == '(')
      ans = (ans + S1[t]) % MOD;
    else if (s[i - 1] == '?')
      ans = (ans + S2[t]) % MOD;
  }
  cout << ans << '\n';
  return 0;
}
