#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 1e6 + 5;
long long n, cnt, ans, l1[N], l2[N], r1[N], r2[N], c1[N], c2[N];
string bracket;
template <typename T>
inline T read() {
  T res = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return f * res;
}
template <typename T>
void write(T n) {
  if (n / 10) write(n / 10);
  putchar(n % 10 + '0');
}
void input() {}
template <typename Type, typename... Types>
void input(Type& arg, Types&... args) {
  arg = read<Type>();
  input(args...);
}
long long qpow(long long n, int k) {
  long long res = 1;
  while (k > 0) {
    if (k & 1) res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}
int main() {
  cin >> bracket;
  bracket.insert(bracket.begin(), ' ');
  n = bracket.size() - 1;
  for (register int i = 1; i <= n; i++)
    if (bracket[i] == '?') cnt++;
  for (register int i = 1; i <= n; i++) {
    l1[i] = l1[i - 1];
    l2[i] = l2[i - 1];
    if (bracket[i] == '(') l1[i]++;
    if (bracket[i] == '?') l2[i]++;
  }
  for (register int i = n; i >= 1; i--) {
    r1[i] = r1[i + 1];
    r2[i] = r2[i + 1];
    if (bracket[i] == ')') r1[i]++;
    if (bracket[i] == '?') r2[i]++;
  }
  c1[0] = c2[0] = 1;
  for (register int i = 1; i <= n; i++)
    c1[i] = c1[i - 1] * (cnt - i + 1) % MOD * qpow(i, MOD - 2) % MOD;
  for (register int i = 1; i <= n; i++)
    c2[i] = c2[i - 1] * (cnt - i) % MOD * qpow(i, MOD - 2) % MOD;
  for (register int i = 1; i < n; i++) {
    int d = r1[i + 1] + r2[i + 1] - l1[i];
    if (d < 0) continue;
    ans = ((ans + l1[i] * c1[d] % MOD) % MOD + l2[i] * c2[d - 1] % MOD) % MOD;
  }
  write(ans);
  return 0;
}
