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;
struct trie {
  long long int ara[870][2], sz;
  bool isSuffix[870];
  trie() {}
  trie(long long int _sz) {
    sz = _sz;
    memset(ara, -1, sizeof(ara));
    memset(isSuffix, false, sizeof(isSuffix));
  }
  void insrt(long long int root, char text[], long long int pos) {
    if (text[pos] == '\0') {
      isSuffix[root] = true;
      return;
    }
    long long int bit = text[pos] - '0';
    if (ara[root][bit] != -1) {
      insrt(ara[root][bit], text, pos + 1);
    } else {
      sz++;
      ara[root][bit] = sz - 1;
      insrt(ara[root][bit], text, pos + 1);
    }
  }
  void print(long long int root) {
    if (ara[root][0] != -1) {
      printf("%lld %lld", ara[root][0], 0LL);
      puts("");
      print(ara[root][0]);
    }
    if (ara[root][1] != -1) {
      printf("%lld %lld", ara[root][1], 1LL);
      puts("");
      print(ara[root][1]);
    }
  }
} T;
long long int n, len;
char str[100];
long long int prefix[100];
long long int dp[42][42][870][2][2];
void input() {
  int i, j;
  char text[100];
  scanf("%lld", &n);
  scanf("%s", str);
  len = strlen(str);
  T = trie(1);
  for (i = 1; i <= len - 1; i++) {
    for (j = i; j <= len - 1; j++) {
      text[j - i] = str[j];
    }
    text[j - i] = '\0';
    T.insrt(0, text, 0);
  }
}
void pre() {
  long long int i, j, k;
  prefix[0] = 0;
  for (k = -1, i = 1; i < len; i++) {
    while (k >= 0 && str[k + 1] != str[i]) {
      k = prefix[k] - 1;
    }
    if (str[k + 1] == str[i]) {
      k++;
    }
    prefix[i] = k + 1;
  }
}
long long int re(long long int pos, long long int maxMatch,
                 long long int suffix, long long int st, long long int sufMask,
                 bool f, bool done) {
  long long int i, j, k, nxt, nwSuffix, nwSufMask;
  bool fChk, doneChk;
  fChk = doneChk = false;
  k = maxMatch - 1;
  if (pos == n) {
    if (f) {
      return 1;
    }
    while (k + 1 != 0) {
      if (sufMask & (1LL << (len - k - 1))) {
        return 1;
      }
      k = prefix[k] - 1;
    }
    return 0;
  }
  if (dp[pos][maxMatch][st][f][done] != -1) {
    return dp[pos][maxMatch][st][f][done];
  }
  while (k >= 0 && str[k + 1] != '0') {
    k = prefix[k] - 1;
  }
  if (str[k + 1] == '0') {
    k++;
  }
  if (k + 1 == len) {
    k = prefix[k] - 1;
    fChk = true;
  }
  if (done) {
    doneChk = done;
    nwSuffix = suffix;
    nxt = st;
    nwSufMask = sufMask;
  } else {
    if (T.ara[st][0] != -1) {
      nxt = T.ara[st][0];
      if (T.isSuffix[nxt]) {
        nwSuffix = pos + 1;
      } else {
        nwSuffix = suffix;
      }
      nwSufMask = sufMask | (1LL << nwSuffix);
      doneChk = done;
    } else {
      doneChk = true;
      nwSuffix = suffix;
      nxt = st;
      nwSufMask = sufMask;
    }
  }
  long long int s1 =
      re(pos + 1, k + 1, nwSuffix, nxt, nwSufMask, f | fChk, done | doneChk);
  fChk = doneChk = false;
  k = maxMatch - 1;
  while (k >= 0 && str[k + 1] != '1') {
    k = prefix[k] - 1;
  }
  if (str[k + 1] == '1') {
    k++;
  }
  if (k + 1 == len) {
    k = prefix[k] - 1;
    fChk = true;
  }
  if (done) {
    doneChk = done;
    nwSuffix = suffix;
    nxt = st;
    nwSufMask = sufMask;
  } else {
    if (T.ara[st][1] != -1) {
      nxt = T.ara[st][1];
      if (T.isSuffix[nxt]) {
        nwSuffix = pos + 1;
      } else {
        nwSuffix = suffix;
      }
      nwSufMask = sufMask | (1LL << nwSuffix);
      doneChk = done;
    } else {
      doneChk = true;
      nwSuffix = suffix;
      nxt = st;
      nwSufMask = sufMask;
    }
  }
  long long int s2 =
      re(pos + 1, k + 1, nwSuffix, nxt, nwSufMask, f | fChk, done | doneChk);
  return dp[pos][maxMatch][st][f][done] = s1 + s2;
}
void solve() {
  pre();
  memset(dp, -1, sizeof(dp));
  long long int s = re(0, 0, 0, 0, 0, false, false);
  printf("%lld", s);
  puts("");
}
int main() {
  input();
  solve();
}
