#include <bits/stdc++.h>
using namespace std;
const long long md = 998244353;
long long fac[1001000], inv[1001000];
long long qp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % md;
    a = a * a % md;
    b >>= 1;
  }
  return ret;
}
long long C[2][1001000];
long long pre[2][1001000];
void init() {
  fac[0] = 1;
  inv[0] = 1;
  for (int i = 1; i < 1001000; i++) {
    fac[i] = fac[i - 1] * i % md;
    inv[i] = qp(fac[i], md - 2);
  }
  return;
}
int pl[1001000], pr[1001000], pu[1001000];
char s[1001000];
int main() {
  scanf("%s", s + 1);
  init();
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    pl[i] = pl[i - 1];
    pr[i] = pr[i - 1];
    pu[i] = pu[i - 1];
    if (s[i] == '(')
      pl[i]++;
    else if (s[i] == ')')
      pr[i]++;
    else
      pu[i]++;
  }
  C[0][0] = C[0][pu[n] - 1] = 1;
  C[1][0] = C[1][pu[n]] = 1;
  pre[0][0] = pre[1][0] = 1;
  for (int i = 1; i < pu[n]; i++) {
    C[0][i] = fac[pu[n] - 1] * inv[i] % md * inv[pu[n] - 1 - i] % md;
    C[1][i] = (C[0][i] + C[0][i - 1]) % md;
    pre[0][i] = (pre[0][i - 1] + C[0][i]) % md;
    pre[1][i] = (pre[1][i - 1] + C[1][i]) % md;
  }
  pre[1][pu[n]] = (pre[1][pu[n] - 1] + C[1][pu[n]]) % md;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long x = pl[i - 1], y = pr[n] - pr[i], d = pu[n] - pu[i];
    if (s[i] == '(' && y - x + d > 0) {
      ans = (ans + pre[1][min(y + d - x - 1, 1ll * pu[n])]) % md;
    } else if (s[i] == '?' && y - x + d > 0) {
      ans = (ans + pre[0][min(y + d - x - 1, 1ll * pu[n] - 1)]) % md;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
