// :E
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
using ii=long long;
const int N = 205;
int dp[2][N][N][N]; // (, [, {
int pd[2][N][N][N];
int z = 0;
const int mod = 1e5;
int lol = 0;
int main()
{
int n;
cin >> n;
string s;
cin >> s;
if (s[0] == '?') {
dp[z][1][0][0] = 1;
dp[z][0][1][0] = 1;
dp[z][0][0][1] = 1;
}
if (s[0] == '(') {
dp[z][1][0][0] = 1;
}
if (s[0] == '[') {
dp[z][0][1][0] = 1;
}
if (s[0] == '{') {
dp[z][0][0][1] = 1;
}
for (int j = 0; j < n; ++j) {
for (int h = 0; h < n; ++h) {
for (int k = 0; k < n; ++k) {
//printf("dp[%d][%d][%d] = %d\n", j, h, k, dp[z][j][h][k]);
}
}
}
//printf("\n\n");
for (int i = 1; i < n; ++i) {
z = !z;
for (int j = 0; j < n; ++j) {
for (int h = 0; h < n; ++h) {
for (int k = 0; k < n; ++k) {
dp[z][j][h][k] = 0;
pd[z][j][h][k] = 0;
}
}
}
if (s[i] == '?') {
for (int j = 0; j < n; ++j) {
for (int h = 0; h < n; ++h) {
for (int k = 0; k < n; ++k) {
if (j > 0) {
dp[z][j][h][k] += dp[!z][j - 1][h][k];
//printf("dp[%d][%d][%d] += dp[%d][%d][%d]\n", j, h, k, j - 1, h, k);
pd[z][j][h][k] |= pd[!z][j - 1][h][k];
}
if (h > 0) {
dp[z][j][h][k] += dp[!z][j][h - 1][k];
//printf("dp[%d][%d][%d] += dp[%d][%d][%d]\n", j, h, k, j, h - 1, k);
pd[z][j][h][k] |= pd[!z][j][h - 1][k];
}
if (k > 0) {
dp[z][j][h][k] += dp[!z][j][h][k - 1];
//printf("dp[%d][%d][%d] += dp[%d][%d][%d]\n", j, h, k, j, h, k - 1);
pd[z][j][h][k] |= pd[!z][j][h][k - 1];
}
dp[z][j][h][k] += dp[!z][j + 1][h][k];
//printf("dp[%d][%d][%d] += dp[%d][%d][%d]\n", j, h, k, j + 1, h, k);
pd[z][j][h][k] |= pd[!z][j + 1][h][k];
dp[z][j][h][k] += dp[!z][j][h + 1][k];
//printf("dp[%d][%d][%d] += dp[%d][%d][%d]\n", j, h, k, j, h+1, k);
pd[z][j][h][k] |= pd[!z][j][h + 1][k];
dp[z][j][h][k] += dp[!z][j][h][k + 1];
//printf("dp[%d][%d][%d] += dp[%d][%d][%d]\n", j, h, k, j, h, k+1);
pd[z][j][h][k] |= pd[!z][j][h][k + 1];
if (dp[z][j][h][k] >= mod) {
pd[z][j][h][k] = 1;
}
dp[z][j][h][k] %= mod;
}
}
}
}
else {
for (int j = 0; j < n; ++j) {
for (int h = 0; h < n; ++h) {
for (int k = 0; k < n; ++k) {
if (s[i] == ')') {
dp[z][j][h][k] += dp[!z][j + 1][k][h];
pd[z][j][h][k] |= pd[!z][j + 1][k][h];
}
if (s[i] == '(') {
if (j > 0) {
dp[z][j][h][k] += dp[!z][j - 1][k][h];
pd[z][j][h][k] |= pd[!z][j - 1][k][h];
}
}
if (s[i] == ']') {
dp[z][j][h][k] += dp[!z][j][k + 1][h];
pd[z][j][h][k] |= pd[!z][j][k + 1][h];
}
if (s[i] == '[') {
if (k > 0) {
dp[z][j][h][k] += dp[!z][j][k - 1][h];
pd[z][j][h][k] |= pd[!z][j][k - 1][h];
}
}
if (s[i] == '}') {
dp[z][j][h][k] += dp[!z][j][k][h + 1];
pd[z][j][h][k] |= pd[!z][j][k][h + 1];
}
if (s[i] == '{') {
if (h > 0) {
dp[z][j][h][k] += dp[!z][j][k][h - 1];
pd[z][j][h][k] |= pd[!z][j][k][h - 1];
}
}
if (dp[z][j][h][k] >= mod) {
pd[z][j][h][k] = 1;
}
dp[z][j][h][k] %= mod;
}
}
}
}
for (int j = 0; j < n; ++j) {
for (int h = 0; h < n; ++h) {
for (int k = 0; k < n; ++k) {
//printf("dp[%d][%d][%d] = %d\n", j, h, k, dp[z][j][h][k]);
}
}
}
//printf("\n\n");
}
if (pd[z][0][0][0]) printf("%05d\n", dp[z][0][0][0]);
else printf("%d\n", dp[z][0][0][0]);
}