Codeforces Round 508 (Div. 2)
F
Wrap Around
Codeforces
2900
原题
← E→
翻译中…

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 \le n \le 40$) — the length of the target string $t$.

翻译中…

The next line contains the string $s$ ($1 \le |s| \le 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.

翻译中…

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".

翻译中…

样例

Input #1
2
0
Output #1
3
InputCopy OutputCopy
Input #2
4
1010
Output #2
2
InputCopy OutputCopy
Input #3
20
10101010101010
Output #3
962
InputCopy OutputCopy
题目信息
题号
1038F
时间限制
2 s
内存限制
256 MB
标签
动态规划
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。