#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 7, mod = 998244353;
int fac[maxn], inv[maxn], sl[maxn], sr[maxn], sx[maxn], sy[maxn];
char s[maxn];
inline int qpow(int a, int b, int c = 1) {
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) c = 1ll * c * a % mod;
  return c;
}
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int C(int n, int m) {
  if (m < 0 || m > n) return 0;
  return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1), ans = 0;
  for (int i = fac[0] = inv[0] = 1; i <= 2 * n; ++i)
    fac[i] = mul(fac[i - 1], i);
  inv[2 * n] = qpow(fac[2 * n], mod - 2);
  for (int i = 2 * n - 1; i; --i) inv[i] = mul(inv[i + 1], i + 1);
  for (int i = 1; i <= n; ++i)
    sl[i] = sl[i - 1] + (s[i] == '('), sx[i] = sx[i - 1] + (s[i] == '?');
  for (int i = n; i; --i)
    sr[i] = sr[i + 1] + (s[i] == ')'), sy[i] = sy[i + 1] + (s[i] == '?');
  for (int i = 1; i <= n; ++i) {
    int l = sl[i], r = sr[i + 1], x = sx[i], y = sy[i + 1];
    ans = add(ans, mul(l, C(x + y, y - l + r))),
    ans = add(ans, mul(x, C(x + y - 1, y - l + r - 1)));
  }
  cout << ans << endl;
  return 0;
}
