#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
char s[1000006];
int n, x[1000006], y[1000006], l[1000006], r[1000006];
long long k[1000006], inv[1000006];
long long ksm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
void init() {
  k[0] = 1;
  for (int i = 1; i < 1000006; i++) k[i] = 1ll * k[i - 1] * i % mod;
  inv[1000006 - 1] = ksm(k[1000006 - 1], mod - 2);
  for (int i = 1000006 - 2; i >= 0; i--)
    inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
}
long long C(long long x, long long y) {
  if (x < 0 || y < 0 || y > x) return 0;
  return (k[x] * inv[y] % mod) * inv[x - y] % mod;
}
int main() {
  init();
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    x[i] = x[i - 1], l[i] = l[i - 1];
    if (s[i] == ')') continue;
    if (s[i] == '(')
      l[i]++;
    else
      x[i]++;
  }
  for (int i = n - 1; i >= 1; i--) {
    y[i] = y[i + 1], r[i] = r[i + 1];
    if (s[i + 1] == '(') continue;
    if (s[i + 1] == ')')
      r[i]++;
    else
      y[i]++;
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += l[i] * C(x[i] + y[i], y[i] + r[i] - l[i]) % mod;
    ans %= mod;
    ans += x[i] * C(x[i] + y[i] - 1, y[i] + r[i] - l[i] - 1) % mod;
    ans %= mod;
  }
  cout << ans;
}
