#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

struct mint{
    long long x;
    long long mod = 998244353;
    
    mint(): x(0) {}
    mint(long long _x) { x = _x % mod; }
    //operator long long() { return x; }

    mint operator+(const mint & b) const { return (x + b.x) % mod; }
    mint operator-(const mint & b) const { return (x - b.x + mod) % mod; }
    mint operator*(const mint & b) const { return (x * b.x) % mod; }

    template<class T>
    mint operator^(T b) const {
        if(!b) return 1;
        mint tmp = (*this) ^ (b / 2);
        return b % 2 ? tmp * tmp * (*this) : tmp * tmp;
    }

    mint inv() const { 
        static unordered_map<long long, long long> inv_dp;
        if(inv_dp.count(x))
            return inv_dp[x];
        else if(inv_dp.size() < 100000)
            return mint(inv_dp[x] = ((*this) ^ (mod - 2)).x);
        else return (*this) ^ (mod - 2);
    }
    
    mint operator/(const mint & b) const { return (*this) * b.inv(); }
};

vector<int> divisors(int k) {
	vector<int> res;
	for(int i = 1; i <= k / i; i++) {
		if(k % i == 0) {
			res.push_back(i);
			if(i != k / i)
				res.push_back(k / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
mint to_mint(string s) {
	mint res(0);
	for(int i = 0; i < s.size(); i++) {
		res = res * mint(2);
		res = res + mint(s[i] - '0');
	}
	return res;
}
 
const int MAXN = 1e6 + 10;

int n, m;
string s, ss;
vector<int> ds;
unordered_map<int, mint> dp;

mint cal(int d) {
	string tmp = s.substr(0, d);
	for(int i = 0; i < d; i++) {
		tmp += (tmp[i] == '1' ? '0' : '1');
	}
	while(tmp.size() < s.size()) tmp += tmp;
	tmp = tmp.substr(0, s.size());

	mint res = to_mint(s.substr(0, d));
	if(tmp <= s)
		return res + mint(1);
	else
		return res;
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;


    cin >> n;
    cin >> s;
    ds = divisors(n);
    // ss = s;
    // for(int i = 0; i < s.size(); i++)
    // 	ss += s[i] == '1' ? '0' : '1';

    for(int d : ds) {
    	// if(d > n) continue;
    	mint tmp = cal(d);
    	debug << d << tmp.x << endl;
    	for(int dd : ds) {
    		if(dd >= d) break;
    		if(d % dd == 0 && d / dd % 2)
    			tmp = tmp - dp[dd];
    	}
    	debug << d << tmp.x << endl;
    	dp[d] = tmp;
    }

    // mint res = (mint(1) + to_mint(s)) * (2 * n);
    mint res = 0;
    for(auto & p : dp) {
    	// res = res + mint(p.first) * mint(2) * p.second;
    	// res = res - p.second * mint(2 * n);
    	if(n / p.first % 2)
	    	res = res + mint(p.first) * mint(2) * p.second;
    }

    cout << res.x << endl;

    return 0;
 
}























Measured memory_bytes: 1348