#include <bits/stdc++.h>
using namespace std;
const int N = 1100000, mod = 998244353;
int n, sum[2][N], fac[N], inv[N], ans;
char s[N];
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
  return;
}
inline long long quickpow(long long base, long long pw) {
  long long ret = 1;
  while (pw) {
    if (pw & 1) ret = ret * base % mod;
    base = base * base % mod, pw >>= 1;
  }
  return ret;
}
inline long long comb(int n, int m) {
  if (n < m || m < 0) return 0;
  return (long long)fac[n] * inv[m] % mod * inv[n - m] % mod;
}
inline int addMod(int a, int b) { return (a += b) >= mod ? a - mod : a; }
int main() {
  int a = 0, b = 0, c = 0;
  scanf("%s", s + 1), n = strlen(s + 1);
  fac[0] = 1;
  for (register int i = 1; i <= n; ++i)
    fac[i] = (long long)fac[i - 1] * i % mod;
  inv[n] = quickpow(fac[n], mod - 2);
  for (register int i = n; i; --i) inv[i - 1] = (long long)inv[i] * i % mod;
  for (register int i = n; i; --i) b += s[i] == ')', c += s[i] == '?';
  sum[0][0] = sum[1][0] = 1;
  for (register int i = 1; i <= n; ++i) {
    sum[0][i] = addMod(sum[0][i - 1], comb(c, i));
    sum[1][i] = addMod(sum[1][i - 1], comb(c - 1, i));
  }
  for (register int i = 1; i <= n; ++i) {
    a += s[i] == '(', b -= s[i] == ')', c -= s[i] == '?';
    if (s[i] == '(' && c + b - a >= 0) ans = addMod(ans, sum[0][c + b - a]);
    if (s[i] == '?' && c + b - a >= 1) ans = addMod(ans, sum[1][c + b - a - 1]);
  }
  cout << ans << endl;
  return 0;
}
