#include <bits/stdc++.h>
using namespace std;
int N, l[1200001], r[1200001], x[1200001], y[1200001], ans, fc[1200001],
    inv[1200001];
string a;
int pow(int a, int b) {
  int ans = 1;
  while (b)
    b& 1 ? ans = 1ll * ans * a % 998244353 : 0, a = 1ll * a * a % 998244353,
           b >>= 1;
  return ans;
}
int C(int a, int b) {
  if (a < 0 || b < 0 || b > a) return 0;
  return 1ll * fc[a] * inv[b] % 998244353 * inv[a - b] % 998244353;
}
int main() {
  cin >> a;
  N = a.length();
  a = " " + a;
  for (int i = 1; i <= N; i++)
    l[i] = l[i - 1] + (a[i] == '('), x[i] = x[i - 1] + (a[i] == '?');
  for (int i = N; i >= 1; i--)
    r[i] = r[i + 1] + (a[i] == ')'), y[i] = y[i + 1] + (a[i] == '?');
  fc[0] = 1;
  for (int i = 1; i <= N; i++) fc[i] = 1ll * fc[i - 1] * i % 998244353;
  inv[N] = pow(fc[N], 998244353 - 2);
  for (int i = N - 1; i >= 0; i--)
    inv[i] = 1ll * inv[i + 1] * (i + 1) % 998244353;
  for (int i = 1; i <= N - 1; i++)
    ans =
        (ans + 1ll * l[i] * C(x[i] + y[i + 1], y[i + 1] + r[i + 1] - l[i]) +
         1ll * x[i] * C(x[i] + y[i + 1] - 1, y[i + 1] + r[i + 1] - l[i] - 1)) %
        998244353;
  cout << ans << endl;
  return 0;
}
