#include <bits/stdc++.h>
using namespace std;
const int CN = 1e6 + 10, P = 998244353;
int add(int x, int y) { return x + y >= P ? x + y - P : x + y; }
int n, fac[CN], ifac[CN], pre[CN], suf[CN], pc[CN], sc[CN], ans;
char ch[CN];
int C(int n, int m) {
  return m < 0 || m > n ? 0 : (long long)fac[n] * ifac[m] % P * ifac[n - m] % P;
}
int main() {
  scanf("%s", ch + 1), n = strlen(ch + 1);
  fac[0] = ifac[0] = ifac[1] = 1;
  for (int i = 1; i <= n; i++) fac[i] = (long long)fac[i - 1] * i % P;
  for (int i = 2; i <= n; i++)
    ifac[i] = (long long)ifac[P % i] * (P - P / i) % P;
  for (int i = 2; i <= n; i++) ifac[i] = (long long)ifac[i - 1] * ifac[i] % P;
  for (int i = 1; i <= n; i++)
    pre[i] = pre[i - 1] + (ch[i] == '('), pc[i] = pc[i - 1] + (ch[i] == '?');
  for (int i = n; i; i--)
    suf[i] = suf[i + 1] + (ch[i] == ')'), sc[i] = sc[i + 1] + (ch[i] == '?');
  for (int i = 1, A, B;
       A = pc[i] + sc[i + 1], B = pc[i] + pre[i] - suf[i + 1], i < n; i++)
    ans = (ans + (long long)pre[i] * C(A, B) + (long long)pc[i] * C(A - 1, B)) %
          P;
  printf("%d\n", ans);
  return 0;
}
