import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import combinations, permutations from math import log,gcd input = lambda :sys.stdin.readline() mi = lambda :map(int,input().split()) li = lambda :list(mi()) mod = 998244353 s = input().rstrip() n = len(s) dp_left = [[0] * (n//2+1) for i in range(n+1)] dp_left[0][0] = 1 for i in range(n): for j in range(n//2+1): if (s[i] == "(" or s[i] == ".") and j+1 <= n//2: dp_left[i+1][j+1] += dp_left[i][j] dp_left[i+1][j+1] %= mod if (s[i] == ")" or s[i] == ".") and 0 <= j-1: dp_left[i+1][j-1] += dp_left[i][j] dp_left[i+1][j-1] %= mod if (s[i] == "?" or s[i] == ".") and j+1 <= n//2: dp_left[i+1][j+1] += dp_left[i][j] dp_left[i+1][j+1] %= mod res = dp_left[n][0] #print(res,dp_left) dp_right = [0] * (n//2+1) dp_right[0] = 1 for i in range(n)[::-1]: ndp = [0] * (n//2+1) for j in range(n//2+1): if (s[i] == ")" or s[i] == ".") and j+1 <= n//2: ndp[j+1] += dp_right[j] ndp[j+1] %= mod if (s[i] == "(" or s[i] == ".") and 0 <= j-1: ndp[j-1] += dp_right[j] ndp[j-1] %= mod if (s[i] == "?" or s[i] == ".") and j+1 <= n//2: ndp[j+1] += dp_right[j] ndp[j+1] %= mod tmp = dp_left[i][j+1] * dp_right[j] % mod res = (res + tmp) % mod dp_right = ndp print(res)