#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
const long long mod = 998244353;
char a[N];
long long l1[N], l2[N], r1[N], r2[N];
long long inv[2 * N], jc[2 * N], jcny[2 * N];
inline long long c(long long nn, long long mm) {
  if (mm > nn) return 0;
  if (mm < 0) return 0;
  return jc[nn] * jcny[mm] % mod * jcny[nn - mm] % mod;
}
signed main() {
  scanf("%s", a + 1);
  long long n = strlen(a + 1);
  inv[1] = 1;
  jc[0] = 1;
  jc[1] = 1;
  jcny[0] = 1;
  jcny[1] = 1;
  for (long long i = 2; i <= 2 * n; i++) {
    jc[i] = jc[i - 1] * i % mod;
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    jcny[i] = jcny[i - 1] * inv[i] % mod;
  }
  for (long long i = 1; i <= n; i++) {
    l1[i] = l1[i - 1];
    l2[i] = l2[i - 1];
    if (a[i] == '(') l1[i]++;
    if (a[i] == '?') l2[i]++;
  }
  for (long long i = n; i >= 1; i--) {
    r1[i] = r1[i + 1];
    r2[i] = r2[i + 1];
    if (a[i] == ')') r1[i]++;
    if (a[i] == '?') r2[i]++;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans = (ans +
           l1[i] * c(l2[i] + r2[i + 1], r2[i + 1] - l1[i] + r1[i + 1]) % mod +
           l2[i] * c(l2[i] + r2[i + 1] - 1, r2[i + 1] - l1[i] + r1[i + 1] - 1) %
               mod) %
          mod;
  }
  cout << ans;
  return 0;
}
