#include <bits/stdc++.h>
using namespace std;
long long jc[1000005], bjc[1000005];
char inp[1000005];
int cnt[3][1000005];
long long ksm(long long a, long long b) {
  if (!b) return 1;
  long long ns = ksm(a, b >> 1);
  ns = ns * ns % 998244353;
  if (b & 1) ns = ns * a % 998244353;
  return ns;
}
int q(int tp, int l, int r) { return cnt[tp][r] - cnt[tp][l - 1]; }
long long c(int a, int b) {
  if (a < b) return 0;
  return jc[a] * bjc[b] % 998244353 * bjc[a - b] % 998244353;
}
long long s[2][1000005];
int main() {
  scanf("%s", inp + 1);
  jc[0] = bjc[0] = 1;
  for (int i = 1; i < 1000005; i++)
    jc[i] = jc[i - 1] * i % 998244353, bjc[i] = ksm(jc[i], 998244353 - 2);
  int l = strlen(inp + 1);
  for (int i = 1; i <= l; i++) {
    for (int j = 0; j < 3; j++) cnt[j][i] = cnt[j][i - 1];
    if (inp[i] == '(')
      cnt[0][i]++;
    else if (inp[i] == ')')
      cnt[2][i]++;
    else
      cnt[1][i]++;
  }
  int sm = q(1, 1, l);
  for (int j = 0; j < 2; j++) {
    int ns = sm - j;
    for (int q = 0; q < 1000005; q++) s[j][q] = c(ns, q);
    for (int q = 1000005 - 2; q >= 0; q--)
      s[j][q] = (s[j][q] + s[j][q + 1]) % 998244353;
  }
  long long ans = 0;
  for (int i = 1; i <= l; i++) {
    if (inp[i] == '(')
      continue;
    else {
      int u = q(1, 1, i - 1);
      int v = q(1, i + 1, l);
      int ldis = 1 + q(2, i + 1, l) - q(0, 1, i - 1);
      ldis += v;
      u += v;
      ans += s[q(1, 1, l) - u][max(ldis, 0)];
      ans %= 998244353;
    }
  }
  if (ans < 0) ans += 998244353;
  cout << ans << endl;
  return 0;
}
