#include <bits/stdc++.h>
using namespace std;
const int Max = 2e3 + 5;
const int Mod = 998244353;
int n, dp[Max][Max];
string s;
int cnt[Max][Max];
int sum(int i, int j) {
  if (i > j) return 1;
  if (cnt[i][j]) return cnt[i][j];
  return cnt[i][j] = (s[i] == '?' ? 2 : 1) * sum(i + 1, j) % Mod;
}
int Try(int l, int r) {
  if (l >= r) return 0;
  int& ret = dp[l][r];
  if (~ret) return ret;
  ret = 0;
  if ((s[l] == '(' || s[l] == '?') && (s[r] == ')' || s[r] == '?'))
    ret = (Try(l + 1, r - 1) + sum(l + 1, r - 1)) % Mod;
  bool b1 = false, b2 = false;
  if (s[l] != '(') ret = (ret + Try(l + 1, r)) % Mod, b1 = true;
  if (s[r] != ')') ret = (ret + Try(l, r - 1)) % Mod, b2 = true;
  if (b1 && b2) ret = (ret - Try(l + 1, r - 1) + Mod) % Mod;
  return ret;
}
int main() {
  cin >> s;
  memset(dp, -1, sizeof(dp));
  n = s.size();
  cout << Try(0, n - 1) << endl;
  return 0;
}
