#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 11, mod = 998244353;
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f -= 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return f * x;
}
int len, ans, mul[N], inv1[N], inv[N];
int l, r, x, y;
char ul[N];
inline void pre_work(int n) {
  inv1[1] = inv[1] = inv1[0] = inv[0] = mul[1] = mul[0] = 1;
  for (int i = 2; i <= n; ++i) {
    inv1[i] = (1ll * (mod - mod / i) * inv1[mod % i]) % mod;
    mul[i] = 1ll * mul[i - 1] * i % mod;
    inv[i] = 1ll * inv1[i] * inv[i - 1] % mod;
  }
}
inline int C(int n, int m) {
  return (n < m || n < 0 || m < 0)
             ? 0
             : ((1ll * mul[n] * inv[m] % mod) * inv[n - m]) % mod;
}
int main(void) {
  scanf("%s", ul + 1);
  len = strlen(ul + 1);
  pre_work(len + 10);
  for (int i = 1; i <= len; ++i) r += (ul[i] == '?'), y += (ul[i] == ')');
  for (int i = 1; i <= len; ++i) {
    l += (ul[i] == '?'), r -= (ul[i] == '?');
    x += (ul[i] == '('), y -= (ul[i] == ')');
    ans = (ans + 1ll * x * C(l + r, r + y - x) % mod +
           1ll * l * C(l + r - 1, r + y - x - 1) % mod) %
          mod;
  }
  printf("%d\n", ans);
  return 0;
}
