#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
using namespace std;
const int P = 998244353;
inline long long quickpow(long long x, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * x % P;
    x = x * x % P;
    k >>= 1;
  }
  return res;
}
int n;
char s[1001000];
long long jie[1001000], jieni[1001000];
inline void init() {
  jie[0] = jieni[0] = 1;
  for (int i = 1; i <= n; ++i) jie[i] = jie[i - 1] * i % P;
  jieni[n] = quickpow(jie[n], P - 2);
  for (int i = n - 1; i; --i) jieni[i] = jieni[i + 1] * (i + 1) % P;
}
inline long long get_c(int n, int m) {
  if (n < 0 || m < 0 || n - m < 0) return 0;
  return jie[n] * jieni[m] % P * jieni[n - m] % P;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init();
  int A = 0, B = 0;
  for (int i = 1; i <= n; ++i) A += s[i] == '?', B += s[i] == '(';
  int C = 0, D = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '(') ++C;
    if (s[i] == '?') ++D;
    int sn = n - i;
    ans = (ans + C * get_c(A, sn - B)) % P;
    ans = (ans + D * get_c(A - 1, sn - B - 1)) % P;
  }
  printf("%lld\n", ans);
  return 0;
}
