#include <bits/stdc++.h>
using namespace std;
char s[1000010];
long long n, jc[1000010], ij[1000010], a[1000010], b[1000010], c[1000010],
    d[1000010];
map<long long, vector<long long> > m;
long long cl(long long x, long long y) {
  if (y > x) return 0;
  return jc[x] * ij[y] % 998244353ll * ij[x - y] % 998244353ll;
}
long long cal(long long a, long long b, long long c, long long d) {
  long long e = min(c - a + d - 1, b + d), s = b + d;
  if (e < 0) return 0;
  if (m.count(s)) return m[s][e];
  m[s].resize(s + 1);
  for (long long i = 0; i <= s; i++) m[s][i] = cl(s, i);
  for (long long i = 1; i <= s; i++)
    m[s][i] = (m[s][i] + m[s][i - 1]) % 998244353ll;
  return m[s][e];
}
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  ij[1] = 1;
  for (long long i = 2; i < 1000010; i++)
    ij[i] = ij[998244353ll % i] * (998244353ll - 998244353ll / i) % 998244353ll;
  jc[0] = jc[1] = ij[0] = 1;
  for (long long i = 2; i < 1000010; i++) {
    ij[i] = ij[i - 1] * ij[i] % 998244353ll;
    jc[i] = jc[i - 1] * i % 998244353ll;
  }
  for (long long i = 1; i <= n; i++) {
    a[i] = a[i - 1] + (s[i] == '(');
    b[i] = b[i - 1] + (s[i] == '?');
  }
  for (long long i = n; i; i--) {
    c[i] = c[i + 1] + (s[i] == ')');
    d[i] = d[i + 1] + (s[i] == '?');
  }
  long long r = 0;
  for (long long i = 1; i <= n; i++)
    if (s[i] == '(' || s[i] == '?')
      r = (r + cal(a[i - 1], b[i - 1], c[i + 1], d[i + 1])) % 998244353ll;
  cout << r;
}
