// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 998244353LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end

using mint = ModInt<MOD>;

int main() {
    int N; cin >> N;
    string X; cin >> X;

    vector<int> divs;
    for(int i=1; i*i<=N; i++) {
        if(N % i == 0) {
            divs.emplace_back(i);
            if(i != N / i) divs.emplace_back(N / i);
        }
    }
    sort(divs.begin(), divs.end());

    mint ans(0);
    map<int, mint> memo;
    for(auto d : divs) {
        if((N / d) % 2 == 0) continue;
        int dig = d, block = N / d;
        vector< vector< vector<mint> > > dp(dig + 1,
                                            vector< vector<mint> >(block + 1,
                                                                   vector<mint>(2)));

        vector<int> violate_0(dig, INF), less_0(dig, INF);
        vector<int> violate_1(dig, INF), less_1(dig, INF);
        for(int i=0; i<dig; i++) {
            // i 桁目を 0 か 1 にする
            for(int j=0; j<block; j++) {
                int k = j * dig + i;
                {
                    char c = (j % 2 ? '0' : '1');
                    if(X[k] < ('0' ^ '1' ^ c)) chmin(violate_0[i], j+1);
                    if(X[k] > ('0' ^ '1' ^ c)) chmin(less_0[i], j+1);
                }
                {
                    char c = (j % 2 ? '1' : '0');
                    if(X[k] < ('1' ^ '0' ^ c)) chmin(violate_1[i], j+1);
                    if(X[k] > ('1' ^ '0' ^ c)) chmin(less_1[i], j+1);
                }
            }
        }
        
        dp[0][0][1] = mint(1);
        // i 桁目まで、j ブロック以降はなんでもいい、違反してるかどうか
        for(int i=0; i<=dig; i++) {
            for(int j=0; j<=block; j++) {
                for(int x=0; x<2; x++) {
                    if(i >= dig) continue;

                    // f より小さいところで violate がおこってはならない
                    int f = (j == 0 ? INF : j);
                    
                    // 0 をいれる
                    {
                        int nx = 1, nf = f;
                        if(x == 0 and violate_0[i] >= min(f, less_0[i])) {
                            nx = 0;
                        }
                        if(x == 1 and less_0[i] < min(f, violate_0[i])) {
                            nx = 0;
                        }

                        chmin(nf, min(less_0[i], violate_0[i]));
                        if(nf >= INF) nf = 0;
                        
                        dp[i+1][nf][nx] += dp[i][j][x];
                    }
                    // 1 をいれる
                    {
                        int nx = 1, nf = f;
                        if(x == 0 and violate_1[i] >= min(f, less_1[i])) {
                            nx = 0;
                        }
                        if(x == 1 and less_1[i] < min(f, violate_1[i])) {
                            nx = 0;
                        }
                        
                        chmin(nf, min(less_1[i], violate_1[i]));
                        if(nf >= INF) nf = 0;
                        
                        dp[i+1][nf][nx] += dp[i][j][x];
                    }
                }
            }
        }

        mint sum = 0;
        for(int i=0; i<=block; i++) sum += dp[dig][i][0];
        sum += dp[dig][0][1];
        
        for(auto e : memo) {
            if(d % e.first != 0) continue;
            sum -= e.second;
        }

        mint coeff(2 * d);

        ans += sum * coeff;
        memo[d] = sum;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 33312