#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int add(int a, int b) { return (a + b) % MOD; }
int sub(int a, int b) { return (a - b + MOD) % MOD; }
int mul(int a, int b) { return ((long long)a * b) % MOD; }
int inv(int a) {
  int b = 1;
  for (int i = 0; (1 << i) <= (MOD - 2); i++) {
    if ((1 << i) & (MOD - 2)) b = mul(b, a);
    a = mul(a, a);
  }
  return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int X = 0;
  for (char c : s)
    if (c == '?') X++;
  vector<int> fact(X + 1);
  fact[0] = 1;
  for (int i = 1; i <= X; i++) fact[i] = mul(fact[i - 1], i);
  vector<int> sum1(X + 2);
  sum1[X + 1] = 0;
  for (int i = X; i >= 0; i--) {
    sum1[i] = mul(fact[X], inv(mul(fact[i], fact[X - i])));
    sum1[i] = add(sum1[i], sum1[i + 1]);
  }
  vector<int> sum2(X + 1);
  sum2[X] = 0;
  for (int i = X - 1; i >= 0; i--) {
    sum2[i] = mul(fact[X - 1], inv(mul(fact[i], fact[X - 1 - i])));
    sum2[i] = add(sum2[i], sum2[i + 1]);
  }
  int A = 0, B = 0, C = 0, sol = 0;
  for (char c : s)
    if (c == ')') C++;
  for (char c : s) {
    if (c == '(') {
      A++;
      int T = max(0, min(X + 1, A + B - C));
      sol = add(sol, sum1[T]);
    } else if (c == '?') {
      B++;
      int T = max(0, min(X, A + B - C));
      sol = add(sol, sum2[T]);
    } else if (c == ')') {
      C--;
    }
  }
  cout << sol;
  return 0;
}
