#include <bits/stdc++.h>
using namespace std;
int n, s1[1000010], s2[1000010], s3[1000010];
long long ans, fac[1000010], inv[1000010], c1[1000010], c2[1000010];
char s[1000010];
inline long long ksm(long long x, long long i) {
  long long res = 1;
  for (; i; i >>= 1, x = x * x % 998244353)
    if (i & 1) res = res * x % 998244353;
  return res;
}
inline long long calc(int m, int n) {
  if (m > n) return 0;
  return fac[n] * inv[m] % 998244353 * inv[n - m] % 998244353;
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  fac[0] = 1;
  for (register int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % 998244353;
    s1[i] = s1[i - 1] + (s[i] == '(');
    s2[i] = s2[i - 1] + (s[i] == ')');
    s3[i] = s3[i - 1] + (s[i] == '?');
  }
  inv[n] = ksm(fac[n], 998244353 - 2);
  for (register int i = n; i; i--) inv[i - 1] = inv[i] * i % 998244353;
  c1[0] = c2[0] = 1;
  for (register int i = 1; i <= s3[n]; i++)
    c1[i] = (c1[i - 1] + calc(i, s3[n])) % 998244353;
  for (register int i = 1; i < s3[n]; i++)
    c2[i] = (c2[i - 1] + calc(i, s3[n] - 1)) % 998244353;
  for (register int i = 1; i <= n; i++) {
    if (s[i] == ')') continue;
    int res = min(s3[n] - (s[i] == '?'),
                  s3[n] - s3[i] + s2[n] - s2[i] - s1[i - 1] - 1);
    if (res < 0) continue;
    if (s[i] == '?')
      ans = (ans + c2[res]) % 998244353;
    else
      ans = (ans + c1[res]) % 998244353;
  }
  printf("%lld", ans);
  return 0;
}
