#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 1e6 + 7;
unordered_map<int, vector<int> > mp;
char s[N];
long long qpow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long cal(long long l, long long r, long long L, long long R) {
  long long n = L + R, m = r + R - l;
  if (m < 0) return 0;
  if (n < m) m = n;
  if (mp.count(n)) return mp[n][m];
  long long res = 1, sum = 1;
  std::vector<int> v;
  for (int i = 0; i <= n; i++) {
    v.push_back(sum);
    res = res * (n - i) % mod * qpow(i + 1, mod - 2) % mod;
    sum = (sum + res) % mod;
  }
  mp[n] = v;
  return mp[n][m];
}
int main() {
  long long ans = 0;
  scanf("%s", s);
  int len = strlen(s);
  int l = 0, L = 0, r = 0, R = 0;
  for (int i = len - 1; i >= 0; i--) {
    if (s[i] == ')') r++;
    if (s[i] == '?') R++;
  }
  for (int i = 0; i < len; i++) {
    if (s[i] == '(') l++;
    if (s[i] == '?') L++, R--;
    if (s[i] == ')') r--;
    if (s[i] == '(') ans = (ans + cal(l, r, L, R)) % mod;
    if (s[i] == '?') {
      l++, L--;
      ans = (ans + cal(l, r, L, R)) % mod;
      l--, L++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
