#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7FFFFFFF;
const long long LINF = 0x7FFFFFFFFFFFFF;
void guan() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long mod = 998244353;
const int maxn = 1010101;
char s[1111];
char ts[1111];
const int N = 111;
long long a[N][N], b[N][N], ta[N][N];
int check(int pos) {
  int len = 0;
  for (int i = 1; i <= pos; i++) {
    int ok = 1;
    for (int j = i; j <= pos && ok; j++) {
      if (s[j - i + 1] != ts[j]) ok = 0;
    }
    if (ok) return pos - i + 1;
  }
  return 0;
}
void matrix_mul(long long a[N][N], long long b[N][N], int n) {
  long long c[N][N];
  memset(c, 0, sizeof(c));
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      a[i][j] = c[i][j];
    }
  }
}
void matrix_qpow(long long a[N][N], int n, int x) {
  long long c[N][N];
  memset(c, 0, sizeof(c));
  for (int i = 0; i <= n; i++) c[i][i] = 1;
  int temp = x;
  for (int i = 1; i <= temp; i++) matrix_mul(c, a, n);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      a[i][j] = c[i][j];
    }
  }
}
void Copy(long long a[][N], long long b[][N], int n) {
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) a[i][j] = b[i][j];
}
int main() {
  guan();
  int d, h, k, p;
  int n, m;
  while (cin >> n >> s + 1) {
    int len = strlen(s + 1);
    memset(a, 0, sizeof(a));
    memset(ta, 0, sizeof(ta));
    for (int i = 0, to; i < len; i++) {
      ts[i + 1] = '1';
      to = check(i + 1);
      a[i][to] = ta[i][to] = 1;
      ts[i + 1] = '0';
      to = check(i + 1);
      a[i][to] = ta[i][to] = 1;
      ts[i + 1] = s[i + 1];
    }
    long long ans = 0;
    for (int i = 0, to; i < len; i++) {
      Copy(a, ta, len);
      matrix_qpow(a, len, n);
      memset(b, 0, sizeof(b));
      b[0][i] = 1;
      matrix_mul(b, a, len);
      ans += b[0][i];
    }
    cout << (long long)pow(2ll, n) - ans << endl;
  }
  return 0;
}
