#include <bits/stdc++.h>
using namespace std;
const int p = 998244353, maxn = 1000011;
int Fact[maxn], nFact[maxn];
char s[maxn];
inline int C(int n, int m) {
  if (n < m || m < 0) return 0;
  return 1LL * Fact[n] * nFact[m] % p * nFact[n - m] % p;
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  Fact[0] = 1;
  for (int i = 1; i <= n; ++i) Fact[i] = 1LL * Fact[i - 1] * i % p;
  nFact[0] = nFact[1] = 1;
  for (int i = 2; i <= n; ++i) nFact[i] = 1LL * (p - p / i) * nFact[p % i] % p;
  for (int i = 1; i <= n; ++i) nFact[i] = 1LL * nFact[i] * nFact[i - 1] % p;
  static int sl[maxn], sq[maxn];
  sl[0] = 0;
  sq[0] = 0;
  for (int i = 1; i <= n; ++i)
    sl[i] = sl[i - 1] + (s[i] == '('), sq[i] = sq[i - 1] + (s[i] == '?');
  int ans = 0;
  for (int qtol = 0; qtol <= sq[n]; ++qtol) {
    int qtor = sq[n] - qtol;
    int SR = (n - sl[n] - sq[n]) + qtor;
    ans = (ans + 1LL * sl[SR] * C(sq[n], qtol)) % p;
    ans = (ans + 1LL * sq[SR] * C(sq[n] - 1, qtol - 1)) % p;
  }
  printf("%d\n", ans);
}
