#include <bits/stdc++.h>
const int kLen = 1000005;
const int mod = 998244353;
char str[kLen];
int sum_left[kLen], sum_right[kLen];
int sum_left_q[kLen], sum_right_q[kLen];
int C[2][kLen];
int pow(int x, int n) {
  int ans = 1;
  while (n) {
    if (n & 1) {
      ans = 1ll * ans * x % mod;
    }
    n >>= 1;
    x = 1ll * x * x % mod;
  }
  return ans;
}
int inv(int x) { return pow(x, mod - 2); }
void get_C(int tot) {
  int fact = 1;
  C[0][0] = 1;
  C[1][0] = 1;
  for (int i = 1; i <= tot; i++) {
    C[0][i] = 1ll * C[0][i - 1] * inv(i) % mod * (tot - i + 1) % mod;
    C[1][i] = 1ll * C[1][i - 1] * inv(i) % mod * (tot - i) % mod;
  }
  for (int i = 1; i <= tot; i++) {
    C[0][i] = (1ll * C[0][i - 1] + C[0][i]) % mod;
    C[1][i] = (1ll * C[1][i - 1] + C[1][i]) % mod;
  }
}
int count(int len) {
  int lp = 1, rp = len;
  int ans = 0;
  while (lp < rp) {
    if (str[lp] == '(' && str[rp] == ')') {
      ans++;
      lp++;
      rp--;
    }
    while (str[lp] == ')') {
      lp++;
    }
    while (str[rp] == '(') {
      rp--;
    }
  }
  return ans;
}
int main() {
  int len;
  scanf("%s", str + 1);
  len = strlen(str + 1);
  sum_left[0] = 0;
  for (int i = 1; i <= len; i++) {
    sum_left[i] = sum_left[i - 1];
    sum_left_q[i] = sum_left_q[i - 1];
    if (str[i] == '(') {
      sum_left[i]++;
    }
    if (str[i] == '?') {
      sum_left_q[i]++;
    }
  }
  sum_right[len + 1] = 0;
  for (int i = len; i >= 1; i--) {
    sum_right[i] = sum_right[i + 1];
    sum_right_q[i] = sum_right_q[i + 1];
    if (str[i] == ')') {
      sum_right[i]++;
    }
    if (str[i] == '?') {
      sum_right_q[i]++;
    }
  }
  int tot_q = len - sum_left[len] - sum_right[1];
  if (tot_q == 0) {
    printf("%d\n", count(len));
  } else if (tot_q == 1) {
    int pos = 0;
    for (int i = 1; i <= len; i++) {
      if (str[i] == '?') {
        pos = i;
        break;
      }
    }
    str[pos] = '(';
    int ans1 = count(len);
    str[pos] = ')';
    int ans2 = count(len);
    printf("%d\n", ans1 + ans2);
  } else {
    get_C(tot_q);
    long long ans = 0;
    for (int i = 1; i <= len; i++) {
      if (str[i] == '(' && sum_right[i] + sum_right_q[i] - sum_left[i] >= 0) {
        if (sum_right[i] + sum_right_q[i] - sum_left[i] > tot_q) {
          ans = (ans + C[0][tot_q]) % mod;
        } else {
          ans = (ans + C[0][sum_right[i] + sum_right_q[i] - sum_left[i]]) % mod;
        }
      }
      if (str[i] == '?' &&
          sum_right[i] + sum_right_q[i] - 1 - sum_left[i] - 1 >= 0) {
        if (sum_right[i] + sum_right_q[i] - 1 - sum_left[i] - 1 >= tot_q) {
          ans = (ans + C[1][tot_q - 1]) % mod;
        } else {
          ans = (ans +
                 C[1][sum_right[i] + sum_right_q[i] - 1 - sum_left[i] - 1]) %
                mod;
        }
      }
    }
    printf("%lld\n", ans);
  }
}
