#include <bits/stdc++.h>
using namespace std;
char S[42];
int n, m, ne[42], nxt[42][2];
long long f[42][42][2], ans;
void getnxt(int x, int t) {
  int j = x;
  while (1) {
    if (j != m && S[j + 1] == t + '0') {
      nxt[x][t] = j + 1;
      break;
    }
    if (!j) break;
    j = ne[j];
  }
}
void getdp(int k) {
  memset(f, 0, sizeof(f));
  f[0][k][k == m] = 1;
  for (register int i = 0; i < n; ++i)
    for (register int j = 0; j <= m; ++j) {
      if (nxt[j][0] == m)
        f[i + 1][nxt[j][0]][1] += f[i][j][0] + f[i][j][1];
      else
        f[i + 1][nxt[j][0]][0] += f[i][j][0],
            f[i + 1][nxt[j][0]][1] += f[i][j][1];
      if (nxt[j][1] == m)
        f[i + 1][nxt[j][1]][1] += f[i][j][0] + f[i][j][1];
      else
        f[i + 1][nxt[j][1]][0] += f[i][j][0],
            f[i + 1][nxt[j][1]][1] += f[i][j][1];
    }
}
int main() {
  scanf("%d", &n);
  scanf("%s", S + 1), m = strlen(S + 1);
  for (register int i = 2; i <= m; ++i) {
    int j = ne[i - 1];
    while (1) {
      if (S[j + 1] == S[i]) {
        ne[i] = j + 1;
        break;
      }
      if (!j) break;
      j = ne[j];
    }
  }
  for (register int i = 0; i <= m; ++i) getnxt(i, 0), getnxt(i, 1);
  for (register int i = 0; i <= m; ++i) getdp(i), ans += f[n][i][1];
  printf("%lld\n", ans);
  return 0;
}
