#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, fac[1000010], inv[1000010], sq[1000010], sl[1000010],
       sr[1000010];
char s[1000010];
template <class T>
void read(T &x) {
  char ch;
  bool ok;
  for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') ok = 1;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  if (ok) x = -x;
}
int c(int x, int y) {
  if (x < y || y < 0) return 0;
  return 1ll * fac[x] * inv[y] % 998244353 * inv[x - y] % 998244353;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  inv[0] = inv[1] = fac[0] = fac[1] = 1;
  for (int i = 2; i <= n; ++i)
    inv[i] = 1ll * (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353;
  for (int i = 2; i <= n; ++i) {
    inv[i] = 1ll * inv[i - 1] * inv[i] % 998244353;
    fac[i] = 1ll * fac[i - 1] * i % 998244353;
  }
  for (int i = 1; i <= n; ++i) sq[i] = sq[i - 1] + (s[i] == '?');
  for (int i = 1; i <= n; ++i) sl[i] = sl[i - 1] + (s[i] == '(');
  for (int i = n; i >= 1; --i) sr[i] = sr[i + 1] + (s[i] == ')');
  for (int i = 1; i <= n; ++i)
    ans =
        (ans +
         1ll * sl[i] * c(sq[n], sq[n] - sq[i] + sr[i + 1] - sl[i]) % 998244353 +
         1ll * sq[i] * c(sq[n] - 1, sq[n] - sq[i] + sr[i + 1] - sl[i] - 1)) %
        998244353;
  printf("%d\n", ans);
  return 0;
}
