#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int n, ans, bin[76][76], msk[76][76];
char need_digits[1 << 20];
string s;
unordered_map<int, int> dp[76];
char sz[20] = {1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5};
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    int j, cur = s[i] - '0';
    for (j = i + 1; j <= n && cur < 21; j++) {
      bin[i][j] = cur;
      if (cur > 0) msk[i][j] = 1 << (bin[i][j] - 1);
      cur = cur * 2 + (s[j] - '0');
    }
    for (; j <= n; j++) bin[i][j] = 100;
    dp[i][0] = 1;
  }
  for (int i = 0; i < (1 << 20); i++) {
    bool was = false;
    for (int j = 19; j >= 0; j--)
      if (i & (1 << j)) {
        if (was) {
          need_digits[i] += need_digits[i & ((1 << (j + 1)) - 1)];
          break;
        }
        was = true;
      } else if (was)
        need_digits[i] += sz[j];
  }
  for (int pos = 0; pos < n; pos++)
    for (int to = pos + 1; to <= n && bin[pos][to] <= 20; to++)
      if (bin[pos][to] > 0)
        for (auto m : dp[pos]) {
          int nmask = m.first | msk[pos][to];
          if (need_digits[nmask] <= n - to) {
            auto &r = dp[to][nmask];
            if ((r += m.second) >= MOD) r -= MOD;
          }
        }
  for (int pos = 1; pos <= n; pos++)
    for (int i = 1; i < (1 << 21); i = i * 2 + 1)
      if ((ans += dp[pos][i]) >= MOD) ans -= MOD;
  cout << ans << endl;
}
