#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 5, mod = 998244353;
long long mul[N], inv[N];
long long ksm(long long f, long long x) {
  long long tot = 1;
  while (x) {
    if (x & 1ll) tot = tot * f % mod;
    f = f * f % mod;
    x >>= 1ll;
  }
  return tot;
}
void pre() {
  long long lim = N - 5;
  mul[0] = inv[0] = 1;
  for (long long i = 1; i <= lim; i++) mul[i] = mul[i - 1] * i % mod;
  inv[lim] = ksm(mul[lim], mod - 2);
  for (long long i = lim - 1; i >= 1; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
long long C(long long m, long long n) {
  if (m < n || m < 0 || n < 0) return 0;
  return mul[m] * inv[n] % mod * inv[m - n] % mod;
}
char s[N];
int n;
int l1, l2, r1, r2, ans;
int main() {
  pre();
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == '?') r1++;
    if (s[i] == ')') r2++;
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] == '?') l1++, r1--;
    if (s[i] == '(') l2++;
    if (s[i] == ')') r2--;
    int d = r1 + r2 - l2;
    ans = (ans + l2 * C(l1 + r1, d) % mod + l1 * C(l1 + r1 - 1, d - 1) % mod) %
          mod;
  }
  cout << ans;
}
