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 n;
string s;
vector<string> substr;
map<string, int> cnt;
const int N = 45;
long long dp[N][N][2][N * N];
void add(int len, int pre, int hav, int suf, char ch) {
  string tmp = s.substr(0, pre);
  tmp += ch;
  while (s.substr(0, tmp.size()) != tmp) {
    tmp = tmp.substr(1);
  }
  int nextpre = tmp.size();
  int nexthav = tmp == s ? 1 : hav;
  int nextsuf = suf;
  if (substr[suf].size() == len) {
    tmp = substr[suf];
    tmp += ch;
    if (cnt.count(tmp)) nextsuf = cnt[tmp];
  }
  dp[len + 1][nextpre][nexthav][nextsuf] += dp[len][pre][hav][suf];
}
long long solve(int len, int pre, int hav, int suf) {
  if (len == n) {
    if (hav)
      return dp[len][pre][hav][suf];
    else {
      string tmp = s.substr(0, pre) + substr[suf];
      if (tmp.find(s) != string::npos)
        return dp[len][pre][hav][suf];
      else
        return 0;
    }
  } else {
    add(len, pre, hav, suf, '0');
    add(len, pre, hav, suf, '1');
    return 0;
  }
}
int main() {
  cin >> n >> s;
  cnt[""] = 0;
  substr.push_back("");
  for (int len = 1; len <= s.size(); len += 1) {
    for (int i = 0; i + len <= s.size(); i += 1) {
      string sstr = s.substr(i, len);
      if (cnt.count(sstr) == 0) {
        cnt[sstr] = substr.size();
        substr.push_back(sstr);
      }
    }
  }
  long long ans = 0;
  dp[0][0][0][0] = 1;
  for (int len = 0; len <= n; len += 1) {
    for (int pre = 0; pre <= len; pre += 1) {
      for (int hav = 0; hav < 2; hav += 1) {
        for (int i = 0; i < substr.size(); i += 1) {
          if (substr[i].size() > len + 1) break;
          ans += solve(len, pre, hav, i);
        }
      }
    }
  }
  cout << ans << endl;
}
