#include <bits/stdc++.h>
using namespace std;
long long n, s[44], len, ne[44], trans[44][2], dp[44][44][2];
char chh[44];
long long getfail(long long x, long long c) {
  for (; x != -1 && s[x + 1] != c; x = ne[x])
    ;
  return x == -1 ? 0 : x + 1;
}
signed main() {
  scanf("%lld", &n);
  scanf("%s", chh + 1);
  len = strlen(chh + 1);
  memset(s, -1, sizeof(s));
  for (long long i = 1; i <= len; i++) s[i] = chh[i] - '0';
  ne[0] = -1;
  long long k = -1;
  for (long long i = 1; i <= len; i++) {
    for (; k > -1 && s[k + 1] != s[i]; k = ne[k])
      ;
    if (k != -1)
      k++;
    else
      k = 0;
    ne[i] = k;
  }
  for (long long i = 0; i <= len; i++) {
    trans[i][0] = getfail(i, 0);
    trans[i][1] = getfail(i, 1);
  }
  long long ans = 0;
  for (long long st = 0; st <= len; st++) {
    memset(dp, 0, sizeof(dp));
    dp[0][st][0] = 1;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j <= len; j++) {
        long long ne = trans[j][0];
        dp[i + 1][ne][ne >= len] += dp[i][j][0];
        dp[i + 1][ne][1] += dp[i][j][1];
        ne = trans[j][1];
        dp[i + 1][ne][ne >= len] += dp[i][j][0];
        dp[i + 1][ne][1] += dp[i][j][1];
      }
    }
    ans += dp[n][st][1];
  }
  printf("%lld\n", ans);
  return 0;
}
