You are given a binary string s.

Find the number of distinct cyclical binary strings of length n which contain s as a substring.

The cyclical string t contains s as a substring if there is some cyclical shift of string t, such that s is a substring of this cyclical shift of t.

For example, the cyclical string "000111" contains substrings "001", "01110" and "10", but doesn't contain "0110" and "10110".

Two cyclical strings are called different if they differ from each other as strings. For example, two different strings, which differ from each other by a cyclical shift, are still considered different cyclical strings.

Input

The first line contains a single integer n (1 ≤ n ≤ 40) — the length of the target string t.

The next line contains the string s (1 ≤ |s| ≤ n) — the string which must be a substring of cyclical string t. String s contains only characters '0' and '1'.

Output

Print the only integer — the number of distinct cyclical binary strings t, which contain s as a substring.

Examples

Input

2
0


Output

3

Input

4
1010


Output

2

Input

20
10101010101010


Output

962

Note

In the first example, there are three cyclical strings, which contain "0" — "00", "01" and "10".

In the second example, there are only two such strings — "1010", "0101".
#include <bits/stdc++.h>
using namespace std;
int lps[50];
char str[50];
void computeLPSArray(char* pat, int M) {
  int len = 0;
  lps[0] = 0;
  int i = 1;
  while (i < M) {
    if (pat[i] == pat[len]) {
      len++;
      lps[i] = len;
      i++;
    } else {
      if (len != 0) {
        len = lps[len - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
}
int len[1600], length[1600], trie[1600][2], nw;
void dfs(int v, int mxlen) {
  length[v] = mxlen;
  for (int i = 0; i <= 1; i++) {
    if (trie[v][i] == 0) continue;
    dfs(trie[v][i], max(len[trie[v][i]], mxlen));
  }
}
int n, sln;
long long dp[42][42][900][2][2];
int ck_dp[50][2];
int Rk[50][50];
int func(int pref, int suff) {
  if (suff == 0 || pref == 0) return 0;
  if (Rk[pref][suff] != -1) return Rk[pref][suff];
  int pos = pref;
  while (1) {
    int k = sln - suff;
    int j;
    int ct = pos;
    for (j = k; str[j]; j++) {
      if (str[j] != str[ct]) break;
      ct++;
    }
    if (ct == sln) return Rk[pref][suff] = 1;
    if (pos == 0) break;
    pos = lps[pos - 1];
  }
  return Rk[pref][suff] = 0;
}
int check_func(int pos, int ch) {
  if (ck_dp[pos][ch] != -2) return ck_dp[pos][ch];
  int v = pos;
  while (str[pos] != (ch + 48)) {
    if (pos != 0)
      pos = lps[pos - 1];
    else
      return ck_dp[v][ch] = -1;
  }
  return ck_dp[v][ch] = pos;
}
long long dp_func(int pos, int pre, int suff, int bol, int bl) {
  if (pos == n) {
    if (bol == 1) return 1;
    int ln;
    assert(bl == 1);
    ln = suff;
    if (ln == sln) return 1;
    return func(pre, suff);
  }
  long long& ret = dp[pos][pre][suff][bol][bl];
  if (ret != -1) return ret;
  ret = 0;
  if (bl == 0) {
    for (int i = 0; i <= 1; i++) {
      int d = check_func(pre, i);
      if (d == -1)
        d = 0;
      else
        d++;
      int g = 0;
      if (d == sln) g = 1;
      if (trie[suff][i] == 0)
        ret += dp_func(pos + 1, d, length[suff], bol || g, 1);
      else
        ret += dp_func(pos + 1, d, trie[suff][i], g || bol, 0);
    }
    return dp[pos][pre][suff][bol][bl] = ret;
  }
  for (int i = 0; i <= 1; i++) {
    int d = check_func(pre, i);
    if (d == -1)
      d = 0;
    else
      d++;
    int g = 0;
    if (d == sln) g = 1;
    ret += dp_func(pos + 1, d, suff, g || bol, 1);
  }
  return dp[pos][pre][suff][bol][bl] = ret;
}
int main() {
  scanf("%d", &n);
  scanf("%s", str);
  sln = strlen(str);
  computeLPSArray(str, sln);
  for (int i = 0; str[i]; i++) {
    int cur = 0;
    for (int j = i; str[j]; j++) {
      if (trie[cur][str[j] - 48] == 0) trie[cur][str[j] - 48] = ++nw;
      cur = trie[cur][str[j] - 48];
    }
    len[cur] = (sln - i);
  }
  dfs(0, 0);
  memset(dp, -1, sizeof dp);
  memset(Rk, -1, sizeof Rk);
  for (int i = 0; i <= 49; i++) ck_dp[i][0] = ck_dp[i][1] = -2;
  long long ret = dp_func(0, 0, 0, 0, 0);
  cout << ret << endl;
}
