#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7, M = 998244353;
int fac[N], invfac[N];
int power(int a, int p) {
  if (p == 0) return 1;
  int ans = power(a, p / 2);
  ans = (1LL * ans * ans) % M;
  if (p % 2) ans = (1LL * ans * a) % M;
  return ans;
}
void pre() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) fac[i] = (1LL * fac[i - 1] * i) % M;
  invfac[N - 1] = power(fac[N - 1], M - 2);
  for (int i = N - 2; i >= 0; i--)
    invfac[i] = (1LL * invfac[i + 1] * (i + 1)) % M;
}
int C(int n, int r) {
  if (r < 0 || r > n) return 0;
  int denom = (1LL * invfac[r] * invfac[n - r]) % M;
  return (1LL * fac[n] * denom) % M;
}
int main() {
  pre();
  string s;
  cin >> s;
  int rclose = 0, rques = 0, lopen = 0, lques = 0;
  for (char c : s)
    if (c == ')')
      rclose++;
    else if (c == '?')
      rques++;
  long long ans = 0;
  for (char c : s) {
    if (c == '(') lopen++;
    if (c == ')') rclose--;
    if (c == '?') lques++, rques--;
    ans = (ans + 1LL * lopen * C(lques + rques, rques + rclose - lopen)) % M;
    ans =
        (ans + 1LL * lques * C(lques + rques - 1, rques + rclose - lopen - 1)) %
        M;
  }
  cout << ans << endl;
}
