n = int(input()) s = input() mod = 998244353 #ans = 1 ans = 1 lt = 0 tmp = 1 for i in range(n): if s[i] == "(": lt += 1 else: if lt > 1: tmp *= lt*2 tmp %= mod lt -= 1 if lt == 0: if tmp == 1: tmp = 2 else: tmp += 2 ans *= tmp ans %= mod tmp = 1 print(ans%mod)