#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10, mod = 998244353;
long long fact[N], finv[N], sum1[N], sum2[N];
long long choose(int n, int k);
long long pwr(long long x, long long e);
long long pwr(long long x, long long e);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.length();
  fact[0] = finv[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = (i * fact[i - 1]) % mod;
    finv[i] = pwr(fact[i], mod - 2);
  }
  int blanks = count(s.begin(), s.end(), '?');
  sum1[0] = 1;
  sum2[0] = (blanks > 0);
  for (int i = 1; i <= n; ++i) {
    sum1[i] = (sum1[i - 1] + choose(blanks, i)) % mod;
    sum2[i] = (sum2[i - 1] + choose(blanks - 1, i)) % mod;
  }
  long long ans = 0, mx = count(s.begin(), s.end(), ')') + blanks;
  for (int i = 0; i < n; ++i) {
    mx -= 1;
    int idx = -1;
    long long* sum = sum1;
    if (s[i] == '(') {
      idx = mx;
      sum = sum1;
    } else if (s[i] == '?') {
      idx = mx - 1;
      sum = sum2;
    }
    ans += (idx >= 0 ? sum[idx] : 0);
  }
  cout << ans % mod << endl;
}
long long choose(int n, int k) {
  if (k < 0 or k > n) {
    return 0;
  } else {
    long long ans = (fact[n] * finv[k]) % mod;
    return (ans * finv[n - k]) % mod;
  }
}
long long pwr(long long x, long long e) {
  long long res = 1;
  while (e) {
    if (e & 1) {
      res = (res * x) % mod;
    }
    x = (x * x) % mod;
    e /= 2;
  }
  return res;
}
