#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 1e6 + 5;
char s[N];
long long fac[N], inv[N], ans;
long long c(long long n, long long m) {
  if (n < m) return 0;
  if (n < 0 || m < 0) return 0;
  return fac[n] * inv[n - m] % mod * inv[m] % mod;
}
int n, lsum[N], sum1[N], rsum[N], sum2[N];
void cal(int a1, int b1, int a2, int b2) {
  int tmp = a2 - a1;
  (ans += 1LL * a1 * c(b1 + b2, b2 + tmp) % mod) %= mod;
  (ans += 1LL * b1 * c(b1 + b2 - 1, b2 + tmp - 1) % mod) %= mod;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  fac[0] = inv[0] = inv[1] = 1;
  for (register int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  for (register int i = 2; i <= n; i++)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  for (register int i = 3; i <= n; i++) inv[i] = inv[i - 1] * inv[i] % mod;
  for (register int i = 1; i <= n; i++)
    lsum[i] = lsum[i - 1] + (s[i] == '('),
    sum1[i] = sum1[i - 1] + (s[i] == '?');
  for (register int i = n; i >= 1; i--)
    rsum[i] = rsum[i + 1] + (s[i] == ')'),
    sum2[i] = sum2[i + 1] + (s[i] == '?');
  for (register int i = 1; i <= n - 1; i++)
    cal(lsum[i], sum1[i], rsum[i + 1], sum2[i + 1]);
  printf("%lld", ans);
}
