#include <bits/stdc++.h>
using namespace std;
long long n, dp[2005][2005], val[2005][2005];
char str[2005];
long long ff(long long, long long), func(long long, long long);
int main() {
  memset(dp, -1, sizeof(dp));
  memset(val, -1, sizeof(val));
  scanf(" %s", str);
  n = strlen(str);
  func(0, n - 1);
  cout << ff(0, n - 1) << "\n";
}
long long ff(long long x, long long y) {
  if (x == y || x > y) return 0;
  if (dp[x][y] != -1) return dp[x][y];
  if (str[x] == ')') return dp[x][y] = ff(x + 1, y);
  if (str[y] == '(') return dp[x][y] = ff(x, y - 1);
  long long qq = func(x + 1, y - 1);
  if (str[x] == '?' && str[y] == '?')
    return dp[x][y] =
               (ff(x + 1, y) + ff(x, y - 1) + qq + 998244353ll) % 998244353ll;
  if (str[x] == '?')
    return dp[x][y] = (ff(x + 1, y) + ff(x + 1, y - 1) + qq) % 998244353ll;
  if (str[y] == '?')
    return dp[x][y] = (ff(x, y - 1) + ff(x + 1, y - 1) + qq) % 998244353ll;
  return dp[x][y] = (ff(x + 1, y - 1) + qq) % 998244353ll;
}
long long func(long long x, long long y) {
  if (x == y || x > y) {
    return (x == y && str[x] == '?') + 1;
  }
  if (val[x][y] != -1) return val[x][y];
  if (str[x] == ')') return val[x][y] = func(x + 1, y);
  if (str[y] == '(') return val[x][y] = func(x, y - 1);
  if (str[x] == '?' && str[y] == '?')
    return val[x][y] =
               (func(x + 1, y) + func(x, y - 1) + 998244353ll) % 998244353ll;
  if (str[x] == '?')
    return val[x][y] = (func(x + 1, y) + func(x + 1, y - 1)) % 998244353ll;
  if (str[y] == '?')
    return val[x][y] = (func(x, y - 1) + func(x + 1, y - 1)) % 998244353ll;
  return val[x][y] = func(x + 1, y - 1);
}
