#include <bits/stdc++.h>
const long long inf = 1e18;
using namespace std;
long long read() {
  long long a = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    a = a * 10 + c - '0';
    c = getchar();
  }
  return a * f;
}
int Fac[1000005], iFac[1000005], x, y, l, r, n;
char s[1000005];
inline int Fp(int x, int k) {
  int ans = 1;
  for (; k; k >>= 1, x = 1ll * x * x % 998244353)
    if (k & 1) ans = 1ll * ans * x % 998244353;
  return ans;
}
inline void Init(int n = 1000005 - 1) {
  Fac[0] = 1;
  for (int i = 1; i <= n; i++) Fac[i] = 1ll * Fac[i - 1] * i % 998244353;
  iFac[n] = Fp(Fac[n], 998244353 - 2);
  for (int i = n; i >= 1; i--) iFac[i - 1] = 1ll * iFac[i] * i % 998244353;
}
inline int C(int n, int m) {
  return n < 0 || m < 0 || n < m
             ? 0
             : 1ll * Fac[n] * iFac[m] % 998244353 * iFac[n - m] % 998244353;
}
int main() {
  scanf("%s", s + 1), n = strlen(s + 1), Init();
  for (int i = 1; i <= n; i++)
    if (s[i] == ')')
      r++;
    else if (s[i] == '?')
      y++;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == ')') r--;
    if (s[i] == '(') l++;
    if (s[i] == '?') y--, x++;
    ans = (ans + 1ll * l * C(x + y, y - l + r) +
           1ll * x * C(x + y - 1, y - l + r - 1)) %
          998244353;
  }
  cout << ans << "\n";
  return 0;
}
