import sys, random input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18 LI = lambda : list(map(int, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()] def debug(_l_): for s in _l_.split(): print(f"{s}={eval(s)}", end=" ") print() def dlist(*l, fill=0): if len(l)==1: return [fill]*l[0] ll = l[1:] return [dlist(*ll, fill=fill) for _ in range(l[0])] s = input() n = len(s) dp = [[0]*(n+1) for _ in range(2)] dp[0][0] = 1 M = 998244353 for i in range(n): ndp = [[0]*(n+1) for _ in range(2)] if s[i]=="(": l = [1] elif s[i]==")": l = [-1] elif s[i]=="?": l = [2,-2] else: l = [1,2,-1,-2] for b in range(2): for j in range(n+1): val = dp[b][j] if val==0: continue for v in l: if v>0: if v==1 or b==0: ndp[b][j+1] += val ndp[b][j+1] %= M elif j>0: if v==-1: ndp[b][j-1] += val ndp[b][j-1] %= M else: # v = -2 ndp[1][j-1] += val ndp[1][j-1] %= M dp = ndp # print(dp) ans = dp[0][0] + dp[1][0] print(ans%M)