#include <bits/stdc++.h>
using namespace std;
const int Mod = 998244353;
int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b) { return 1ll * a * b % Mod; }
void Add(int &a, int b) { a = add(a, b); }
void Dec(int &a, int b) { a = dec(a, b); }
void Mul(int &a, int b) { a = mul(a, b); }
int ksm(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, Mul(a, a))
    if (b & 1) Mul(ans, a);
  return ans;
}
const int N = 1e6 + 50;
int n, fc[N], ifc[N];
int pr[N], sf[N], a[N], b[N];
char S[N];
int A[N], B[N];
int C(int n, int m) {
  if (n < 0 || m < 0 || n < m) return 0;
  return mul(fc[n], mul(ifc[m], ifc[n - m]));
}
int main() {
  scanf("%s", S + 1);
  n = strlen(S + 1);
  for (int i = 1; i <= n; i++)
    pr[i] = pr[i - 1] + (S[i] == '('), a[i] = a[i - 1] + (S[i] == '?');
  for (int i = n; i; i--)
    sf[i] = sf[i + 1] + (S[i] == ')'), b[i] = b[i + 1] + (S[i] == '?');
  fc[0] = fc[1] = ifc[0] = 1;
  for (int i = 2; i <= n; i++) fc[i] = mul(fc[i - 1], i);
  ifc[n] = ksm(fc[n], Mod - 2);
  for (int i = n - 1; i; i--) ifc[i] = mul(ifc[i + 1], i + 1);
  A[0] = B[0] = 1;
  int all = b[1];
  for (int i = 1; i <= n; i++)
    A[i] = add(A[i - 1], C(all - 1, i)), B[i] = add(B[i - 1], C(all, i));
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (S[i] != ')') {
      int t = a[i - 1] + b[i + 1];
      int l = pr[i - 1], r = sf[i + 1];
      if (r - l + b[i + 1] <= 0) continue;
      if (t == all)
        Add(ans, B[r - l + b[i + 1] - 1]);
      else
        Add(ans, A[r - l + b[i + 1] - 1]);
    }
  cout << ans;
  return 0;
}
