#include <bits/stdc++.h>
using namespace std;
char a[1000005];
int n, fc[1000005], inv[1000005], sum[1000005], Sum[1000005];
int C(int n, int m) {
  return 1ll * fc[n] * inv[m] % 998244353 * inv[n - m] % 998244353;
}
int main() {
  fc[0] = fc[1] = inv[0] = inv[1] = 1;
  for (int i = 2; i < 1000005; ++i) fc[i] = 1ll * i * fc[i - 1] % 998244353;
  for (int i = 2; i < 1000005; ++i)
    inv[i] = (998244353 - 1ll * 998244353 / i) * inv[998244353 % i] % 998244353;
  for (int i = 2; i < 1000005; ++i)
    inv[i] = 1ll * inv[i - 1] * inv[i] % 998244353;
  scanf("%s", a + 1);
  n = strlen(a + 1);
  int sum1 = 0, sum2 = 0;
  for (int i = 1; i <= n; ++i) {
    sum1 += a[i] == ')';
    sum2 += a[i] == '?';
  }
  for (int i = 0; i < sum2; ++i) sum[i] = C(sum2 - 1, i);
  for (int i = sum2 - 1; i >= 0; --i)
    sum[i] = (sum[i] + sum[i + 1]) % 998244353;
  for (int i = 0; i <= sum2; ++i) Sum[i] = C(sum2, i);
  for (int i = sum2; i >= 0; --i) Sum[i] = (Sum[i] + Sum[i + 1]) % 998244353;
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (a[i] == '?' || a[i] == '(') {
      int w = max(0, i - sum1);
      if (a[i] == '?')
        ans = (ans + sum[w]) % 998244353;
      else
        ans = (ans + Sum[w]) % 998244353;
    }
  printf("%d", ans);
}
