#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
const int N = 40 + 10;
char str[N];
int nxt[N][2];
long long dp[N][N][2];
int main() {
  int n, m;
  scanf("%d%s", &n, str);
  string s(str);
  m = s.size();
  for (int i = 0; i <= m; ++i) {
    for (int j = 0; j < 2; ++j) {
      string S = s.substr(0, i) + (char)('0' + j);
      for (int k = min(m, i + 1); k >= 0; --k) {
        if (S.substr(i + 1 - k) == s.substr(0, k)) {
          nxt[i][j] = k;
          break;
        }
      }
    }
  }
  long long ret = 0;
  for (int x = 0; x <= m; ++x) {
    memset(dp, 0, sizeof(dp));
    dp[0][x][x == m] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= m; ++j) {
        int k = nxt[j][0];
        dp[i + 1][k][k == m] += dp[i][j][0];
        dp[i + 1][k][1] += dp[i][j][1];
        k = nxt[j][1];
        dp[i + 1][k][k == m] += dp[i][j][0];
        dp[i + 1][k][1] += dp[i][j][1];
      }
    }
    ret += dp[n][x][1];
  }
  printf("%lld\n", ret);
  return 0;
}
