#include <bits/stdc++.h>
using namespace std;
int test = 0;
const int MAXN = 1000009;
const long long MOD = 119 << 23 | 1;
class {
 public:
  string s;
  long long inv[MAXN], n;
  long long c1[MAXN], c2[MAXN];
  long long deg[MAXN], invdeg[MAXN];
  void solve() {
    cin >> s;
    int a = 0;
    n = s.length();
    int A = 0, B = 0, C = 0, D = 0;
    for (char c : s) {
      if (c == '?') ++a;
      if (c == ')') ++C;
    }
    D = a;
    inv[1] = 1;
    for (int i = 2; i < MAXN; ++i) {
      inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    }
    deg[0] = 1;
    for (int i = 1; i < MAXN; ++i) deg[i] = deg[i - 1] * i % MOD;
    invdeg[0] = invdeg[1] = 1;
    for (int i = 2; i < MAXN; ++i) invdeg[i] = invdeg[i - 1] * inv[i] % MOD;
    for (int i = 0; i <= a; ++i) {
      c1[i] = deg[a] * invdeg[i] % MOD * invdeg[a - i] % MOD;
      if (i - 1 >= 0) c1[i] = (c1[i - 1] + c1[i]) % MOD;
    }
    if (a - 1 >= 0) {
      for (int i = 0; i <= a - 1; ++i) {
        c2[i] = deg[a - 1] * invdeg[i] % MOD * invdeg[a - 1 - i] % MOD;
        if (i - 1 >= 0) c2[i] = (c2[i - 1] + c2[i]) % MOD;
      }
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '(') {
        int cur = C - A + D - 1;
        cur = min(cur, a);
        if (cur >= 0) ans = (ans + c1[cur]) % MOD;
        A++;
      } else if (s[i] == ')') {
        C--;
      } else {
        D--;
        int cur = C - A + D - 1;
        cur = min(cur, a - 1);
        if (cur >= 0) ans = (ans + c2[cur]) % MOD;
        B++;
      }
    }
    cout << ans;
  }
} NSPACE;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}
