#include <bits/stdc++.h>
using namespace std;
const int mo = 998244353;
const int N = 1000005;
char s[N];
int n, ans;
int fac[N], inv[N];
int S1[N], S2[N];
int c[N], b[N], a[N];
int C(int x, int y) {
  if (x < 0 || y < 0 || y > x) return 0;
  return 1ll * fac[x] * inv[y] % mo * inv[x - y] % mo;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  fac[0] = inv[0] = inv[1] = 1;
  for (int i = (int)(2); i <= (int)(n); i++)
    inv[i] = 1ll * inv[mo % i] * (mo - mo / i) % mo;
  for (int i = (int)(1); i <= (int)(n); i++)
    inv[i] = 1ll * inv[i - 1] * inv[i] % mo;
  for (int i = (int)(1); i <= (int)(n); i++) fac[i] = 1ll * fac[i - 1] * i % mo;
  for (int i = (int)(1); i <= (int)(n); i++) a[i] = a[i - 1] + (s[i] == '?');
  for (int i = (int)(1); i <= (int)(n); i++) b[i] = b[i - 1] + (s[i] == '(');
  for (int i = (int)(1); i <= (int)(n); i++) c[i] = c[i - 1] + (s[i] == ')');
  for (int i = (int)(0); i <= (int)(n); i++)
    S1[i + 1] = (S1[i] + C(a[n], i)) % mo;
  for (int i = (int)(0); i <= (int)(n); i++)
    S2[i + 1] = (S2[i] + C(a[n] - 1, i)) % mo;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (s[i] != ')') {
      int sum = b[i - 1] + 1 - (c[n] - c[i]) - (a[n] - a[i]);
      ans =
          (ans + (s[i] == '?' ? S2[max(-sum + 1, 0)] : S1[max(-sum + 1, 0)])) %
          mo;
    }
  printf("%d\n", ans);
}
