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