#include <bits/stdc++.h>
using namespace std;
long long int fa[1000020];
long long int p = 998244353;
pair<long long int, long long int> ogh(long long int a, long long int b) {
  if (a == 1) return {b + 1, 1};
  if (b == 1) return {1, a - 1};
  pair<long long int, long long int> ans = ogh(a % b, b % a);
  if (a > b) {
    ans.second += (a / b) * ans.first;
  } else {
    ans.first += (b / a) * ans.second;
  }
  return ans;
}
long long int bi(int m, int n) {
  if (n < 0) return 0;
  if (n > m) return 0;
  if (n == 0 && m == 0) return 1;
  long long int ans = fa[m];
  long long int u = ogh(fa[n], p).first;
  long long int z = ogh(fa[m - n], p).first;
  ans = (((ans * z) % p) * u) % p;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin.tie(0);
  string a;
  cin >> a;
  int s = a.length();
  a.append("#");
  fa[0] = 1;
  for (int i = 1; i < s + 12; i++) fa[i] = (fa[i - 1] * i) % p;
  int s1 = 0, s2 = 0, un1 = 0, un2 = 0;
  for (int i = 0; i < s; i++) {
    if (a[i] == '?') un2++;
    if (a[i] == ')') s2++;
  }
  long long int ans = 0;
  for (int j = 0; j < s + 1; j++) {
    int m = un1;
    int n = un2;
    ans += bi(m + n, n + s2 - s1) * s2;
    ans += n * bi(m + n - 1, n + s2 - s1);
    ans = ans % p;
    if (a[j] == '?') un1++, un2--;
    if (a[j] == ')') s2--;
    if (a[j] == '(') s1++;
  }
  cout << ans << endl;
  return 0;
}
