N=int(input()) S=["*"]+[1 if s=="(" else -1 for s in input()] T=[0]*(N+1) for i in range(1,N+1): T[i]=T[i-1]+S[i] Mod=998244353 DP=[[0]*(N//2+1) for _ in range(N+1)]; DP[0][0]=1 for i in range(1,N+1): for j in range(N//2+1): # 赤に塗る if S[i]==1: if j-1>=0: DP[i][j]+=DP[i-1][j-1] else: if j+1<=N//2: DP[i][j]+=DP[i-1][j+1] # 青に塗る if S[i]==1: if T[i]-j<=N//2: DP[i][j]+=DP[i-1][j] else: if T[i]-j>=0: DP[i][j]+=DP[i-1][j] for j in range(N//2+1): DP[i][j]%=Mod print(DP[N][0])