#include <bits/stdc++.h>
using namespace std;
template <class T>
using v2d = vector<vector<T> >;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 1e6 + 10;
const long long mod = 998244353;
long long fact[2000010], ifact[2000010];
long long power(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) {
      r = r * a % mod;
    }
    b /= 2;
    a = a * a % mod;
  }
  return r;
}
void init() {
  fact[0] = 1;
  for (int i = 1; i <= 2e6; ++i) {
    fact[i] = fact[i - 1] * i % mod;
  }
  ifact[2000000] = power(fact[2000000], mod - 2);
  for (int i = 1999999; i >= 0; --i) {
    ifact[i] = ifact[i + 1] * (i + 1) % mod;
  }
}
long long nCk(int n, int k) {
  if (k < 0 || k > n) {
    return 0LL;
  }
  return fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}
int n, x, y, p, q;
char s[maxN];
long long ans = 0;
void solve() {
  cin >> (s + 1);
  n = strlen(s + 1);
  x = y = p = q = 0;
  for (int i = 1; i <= (int)(n); ++i) {
    if (s[i] == ')') {
      q++;
    } else if (s[i] == '?') {
      y++;
    }
  }
  for (int i = (int)(0); i <= (int)(n); ++i) {
    ans += p * nCk(x + y, y + q - p) % mod;
    if (x + y >= 1) {
      ans += x * nCk(x + y - 1, y + q - p - 1) % mod;
    }
    if (i < n) {
      if (s[i + 1] == '?') {
        y--;
        x++;
      } else if (s[i + 1] == '(') {
        p++;
      } else {
        q--;
      }
    }
  }
  ans %= mod;
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
