#include <bits/stdc++.h>
using namespace std;
int n, l1, l2, r1, r2, d;
char s[1000000 + 5];
long long inv[1000000 + 5], frc[1000000 + 5], now, ans;
inline long long mpow(long long x, int y = 998244353 - 2) {
  long long ans = 1;
  while (y)
    y & 1 && (ans = ans * x % 998244353), y >>= 1, x = x * x % 998244353;
  return ans;
}
int main() {
  register int i;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  frc[0] = 1;
  for (i = 1; i <= n; i++) r1 += (s[i] == ')'), r2 += (s[i] == '?');
  for (i = 1; i <= n; i++) frc[i] = frc[i - 1] * i % 998244353;
  now = mpow(frc[n]);
  for (i = n; ~i; i--) inv[i] = now, now = now * i % 998244353;
  for (i = 1; i < n; i++) {
    l1 += (s[i] == '(');
    l2 += (s[i] == '?');
    r1 -= (s[i] == ')');
    r2 -= (s[i] == '?');
    if (l1 + l2 < r1 || r1 + r2 < l1) continue;
    d = r1 + r2 - l1;
    ans += inv[l2 + r2 - d] *
           (l1 * frc[l2 + r2] % 998244353 * inv[d] % 998244353 +
            l2 * frc[l2 + r2 - 1] % 998244353 * inv[d - 1] % 998244353) %
           998244353;
  }
  printf("%lld\n", ans % 998244353);
}
