#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
const long long mod = 998244353;
char s[N];
int n;
long long jc[N], ny[N], fny[N], sum[3][N], ans[N];
long long C(int n, int m) {
  return (n < m || n < 0 || m < 0)
             ? (0)
             : 1ll * jc[n] * ny[m] % mod * 1ll * ny[n - m] % mod;
}
int main() {
  jc[0] = 1;
  jc[1] = 1;
  ny[0] = 1;
  ny[1] = 1;
  fny[0] = 1;
  fny[1] = 1;
  cin >> (s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    sum[0][i] = sum[0][i - 1];
    sum[1][i] = sum[1][i - 1];
    sum[2][i] = sum[2][i - 1];
    if (s[i] == '?') sum[0][i]++;
    if (s[i] == '(') sum[1][i]++;
    if (s[i] == ')') sum[2][i]++;
  }
  for (long long i = 2; i <= n * 2; i++) {
    jc[i] = jc[i - 1] * i % mod;
    fny[i] = fny[mod % i] * (mod - mod / i) % mod;
    ny[i] = ny[i - 1] * fny[i] % mod;
  }
  for (int i = 1; i <= n; i++) {
    long long x = sum[0][i], y = sum[0][n] - sum[0][i];
    long long ll = sum[1][i], rr = sum[2][n] - sum[2][i];
    ans[i] = (1ll * C(x + y, y - ll + rr) % mod * 1ll * ll +
              1ll * C(x + y - 1, y - ll + rr - 1) % mod * 1ll * x) %
             mod;
  }
  long long pans = 0;
  for (int i = 1; i <= n; i++) pans += ans[i], pans %= mod;
  cout << pans << endl;
}
