#include <bits/stdc++.h>
const int mod = 998244353;
using namespace std;
int n;
char s[1000050];
int l[1000050], r[1000050], x[1000050], y[1000050];
inline int qpow(int d, int z) {
  int ret = 1;
  for (; z; z >>= 1, d = 1ll * d * d % mod)
    if (z & 1) ret = 1ll * ret * d % mod;
  return ret;
}
int inc[1000050], inv[1000050];
inline int C(int n, int m) {
  if (m < 0 || m > n) return 0;
  return 1ll * inc[n] * inv[m] % mod * inv[n - m] % mod;
}
inline void init(int n) {
  inc[0] = inv[0] = 1;
  for (int i = 1; i <= n; ++i) inc[i] = 1ll * inc[i - 1] * i % mod;
  inv[n] = qpow(inc[n], mod - 2);
  for (int i = n - 1; i; --i) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init(n);
  for (int i = 1; i <= n; ++i)
    l[i] = l[i - 1] + (s[i] == '('), x[i] = x[i - 1] + (s[i] == '?');
  for (int i = n; i; --i)
    r[i] = r[i + 1] + (s[i] == ')'), y[i] = y[i + 1] + (s[i] == '?');
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    ans = (1ll * l[i] * C(x[i] + y[i + 1], y[i + 1] - l[i] + r[i + 1]) + ans) %
          mod;
    ans = (1ll * x[i] * C(x[i] + y[i + 1] - 1, y[i + 1] - l[i] + r[i + 1] - 1) +
           ans) %
          mod;
  }
  cout << ans << endl;
  return 0;
}
