import copy n = int(input()) s = input() mod = 998244353 dpb = [[0]*(n//2+1) for i in range((n//2+1))] dpn = [[0]*(n//2+1) for i in range((n//2+1))] cnt = 1 dpb[0][1] = 1 dpb[1][0] = 1 for i in range(1,n): #dpn = ori[:] #print(dpn,ori,"ori_??") if s[i] == "(": cnt += 1 for j in range(cnt): dpn[cnt-1-j][j+1] += dpb[cnt-1-j][j] dpn[cnt-1-j][j+1] %= mod dpn[cnt-j][j] += dpb[cnt-1-j][j] dpn[cnt-j][j] %= mod else: for j in range(cnt): dpn[cnt-1-j][j] += dpb[cnt-j][j] dpn[cnt-1-j][j] %= mod dpn[cnt-1-j][j] += dpb[cnt-j-1][j+1] dpn[cnt-1-j][j] %= mod #print(cnt-j,j) #cnt -= 1 dpb = copy.deepcopy(dpn) #print(dpn,dpb) if s[i] == "(": for j in range(cnt): dpn[cnt-1-j][j+1] = 0 dpn[cnt-j][j] = 0 else: for j in range(cnt): dpn[cnt-1-j][j] = 0 dpn[cnt-1-j][j] = 0 cnt -= 1 print(dpb[0][0]%mod)