#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, mod = 998244353;
int n, sl, fh, ans, f1[1000010], f2[1000010], fac[1000010], ifc[1000010];
char s[1000010];
int rd() {
  sl = 0;
  fh = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = getchar();
  return sl * fh;
}
void upd(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
int _pow(int k, int i) {
  int t = 1;
  for (; i; i >>= 1, k = 1ll * k * k % mod)
    if (i & 1) t = 1ll * t * k % mod;
  return t;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  fac[0] = 1;
  int p1 = 0, p2 = 0;
  for (int i = 1; i <= n; ++i) fac[i] = 1ll * i * fac[i - 1] % mod;
  ifc[n] = _pow(fac[n], mod - 2);
  for (int i = n; i; --i) ifc[i - 1] = 1ll * i * ifc[i] % mod;
  for (int i = 1; i <= n; ++i) p1 += s[i] == '?', p2 -= s[i] == ')';
  for (int i = p1; ~i; --i)
    f1[i] = (f1[i + 1] + 1ll * fac[p1] * ifc[i] % mod * ifc[p1 - i]) % mod;
  p1--;
  for (int i = p1; ~i; --i)
    f2[i] = (f2[i + 1] + 1ll * fac[p1] * ifc[i] % mod * ifc[p1 - i]) % mod;
  p1++;
  for (int i = 1; i <= n; ++i) {
    p2 += (s[i] == ')') + (s[i] != ')');
    if (s[i] == '?') upd(ans, f2[max(0, p2)]);
    if (s[i] == '(') upd(ans, f1[max(0, p2)]);
  }
  printf("%d\n", ans);
  return 0;
}
