#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 1e6 + 5;
int add(int x, int y) {
  if ((x += y) >= mod) x -= mod;
  return x;
}
int mul(int x, int y) {
  long long z = (long long)x * y;
  return z - z / mod * mod;
}
int powt(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}
char s[maxn];
int p[maxn], inv[maxn];
int C(int n, int m) {
  if (n < 0 || m < 0 || n < m) return 0;
  return mul(p[n], mul(inv[m], inv[n - m]));
}
int main() {
  int n, a = 0, b = 0, x = 0, y = 0, ans = 0, w0 = 0, w1 = 0;
  scanf(" %s", s);
  n = strlen(s);
  p[0] = 1;
  for (int i = 1; i <= n; ++i) p[i] = mul(p[i - 1], i);
  inv[n] = powt(p[n], mod - 2);
  for (int i = n; i > 0; --i) inv[i - 1] = mul(inv[i], i);
  for (int i = 0; i < n; ++i) {
    if (s[i] == ')') b++;
    if (s[i] == '?') y++;
  }
  for (int i = 0; i < n; ++i) {
    w0 = add(w0, C(x + y, a - b + x));
    w1 = add(w1, C(x + y - 1, a - b + x - 1));
    if (s[i] == '(')
      a++;
    else if (s[i] == ')')
      b--;
    else
      x++, y--;
    if (s[i] == ')')
      ans = add(ans, w0);
    else if (s[i] == '?')
      ans = add(ans, w1);
  }
  cout << ans << endl;
  ;
  return 0;
}
