#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int mxn = 1000001, k = 4;
const char c[k] = {'(', ')', '?', '?'};
int n;
string second;
long long first[mxn], rf[mxn], iv[mxn], a[k];
vector<long long> dp[mxn];
long long sol() {
  int x = a[2] + a[3], y = a[1] + a[3] - a[0] - 1;
  if (y < 0) return 0;
  if (!dp[x].empty()) return dp[x][min(x, y)];
  dp[x].resize(x + 1);
  dp[x][0] = 1;
  for (int i = 1; i <= x; i++) {
    dp[x][i] = (first[x] * rf[i] % mod * rf[x - i] + dp[x][i - 1]) % mod;
  }
  return dp[x][min(x, y)];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> second;
  n = second.size();
  for (int i = 1; i < k; i += 2)
    a[i] = count(second.begin(), second.end(), c[i]);
  first[0] = rf[0] = iv[0] = 1;
  for (int i = 1; i <= n; i++) {
    iv[i] = ~-i ? mod - mod / i * iv[mod % i] % mod : 1;
    first[i] = i * first[i - 1] % mod;
    rf[i] = iv[i] * rf[i - 1] % mod;
  }
  long long ret = 0;
  for (long long i = 0; i < n; i++) {
    for (int j = 1; j < k; j += 2) a[j] -= (second[i] == c[j]);
    if (!((find(c, c + k, second[i]) - c) & 1)) (ret += sol()) %= mod;
    for (int j = 0; j < k; j += 2) a[j] += (second[i] == c[j]);
  }
  cout << ret << '\n';
  return 0;
}
