import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //


void solve(){
	Finite.mod = 998244353;
	
	int n = rint;
	string x = rstring;
	
	int[] ds;
	foreach(d; 3 .. n + 1) if(d % 2 > 0 && n % d == 0) ds ~= d;
	log("ds:", ds);
	
	bool isOk(string pa, string total){
		long m = pa.length; // たとえば n = 6, d = 3, m = 2
		foreach(i, c; total){
			long j = i % m;
			long k = i / m;
			char c1;
			if(k % 2 == 0) c1 = pa[j];
			else c1 = (pa[j] == '0')? '1': '0';
			if(c1 == '0' && c == '1') return true;
			if(c1 == '1' && c == '0') return false;
		}
		return true;
	}
	
	Finite toFinite(string u){
		Finite f = Finite(0);
		foreach(c; u){
			f *= 2;
			if(c == '1') f += 1;
		}
		return f;
	}
	
	bool isPrime(long p){
		static bool[long] memo;
		if(p !in memo){
			if(p == 1) memo[p] = 0;
			else foreach(i; 2 .. p){
				if(p % i == 0){
					memo[p] = 0;
					break;
				}
				if(i * i > p){
					memo[p] = 1;
					break;
				}
			}
		}
		return memo[p];
	}
	
	Finite[long] count;
	foreach(d; ds){
		string z = x[0 .. n / d];
		if(isOk(z, x)) count[d] = toFinite(z) + 1;
		else count[d] = toFinite(z);
		log("d:", d, "z:", z, "isOk:", isOk(z, x), "count:", count);
	}
	
	
	ds.sort!"a>b"();
	foreach(d; ds){
		foreach(d2; ds){
			if(d != d2 && d % d2 == 0){
				count[d2] -= count[d];
				log("d:", d, "d2:", d2, "count:", count);
			}
		}
	}

	
	Finite restcount = toFinite(x) + 1;
	foreach(d; ds) restcount -= count[d];
	
	Finite ans = restcount * (n * 2);
	foreach(d; ds) ans += count[d] * (n * 2 / d);
	log("ans:", ans);
	
	ans.writeln;
	
	
	
}

/*
たいていは周期は2N。
そうでないものをさがす。

Nの奇数の約数 d に対して、
N / d 個の1や0が交互に並んだもの
たとえば N = 12、d = 3で 111100001111
は、周期が2N / d になる。

Nの1より大きい奇数の約数をすべてさがし、
それぞれについて、
N / d 個の1や0が交互に並んだものは
Xよりも大きいか小さいか調べる。

*/

import std.conv;
struct Finite{
	ulong value; static ulong mod = 1_000_000_007;
	private static ulong[] _inv = [0, 1], _frac = [1, 1], _invfrac = [1, 1];
	this(ulong v){ value = v % mod; }
	bool opCast(T: bool)(){ return value != 0; }
	Finite opUnary(string s){ ulong v;
		if(s == "+") v = value;
		else if(s == "-") v = mod - value;
		else if(s == "++") v = value + 1;
		else if(s == "--") v = value + mod - 1;
		else assert(0, "Operator unary " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opBinary(string s)(Finite b){
		return opBinary!s(b.value);
	}
	Finite opBinary(string s)(ulong u){ ulong v;
		if(s == "+") v = value + u;
		else if(s == "-") v = value + mod - u;
		else if(s == "*") v = value * u;
		else if(s == "/") v = value * inv(u);
		else assert(0, "Operator " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opBinaryRight(string s)(ulong u){ ulong v;
		if(s == "+") v = u + value;
		else if(s == "-") v = u + mod - value;
		else if(s == "*") v = u * value;
		else if(s == "/") v = u * invvalue;
		else assert(0, "Operator " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opAssign(ulong v){ value = v; return this; }
	Finite opOpAssign(string s)(Finite b){
		return opOpAssign!s(b.value);
	}
	Finite opOpAssign(string s)(ulong v){
		if(s == "+") value = (value + v) % mod;
		else if(s == "-") value = (value + mod - v) % mod;
		else if(s == "*") value = (value * v) % mod;
		else if(s == "/") value = (value * inv(v)) % mod;
		else assert(0, "Operator " ~ s ~ "= not implemented");
		return this;
	}
	bool opEquals(Finite b){
		return(value == b.value);
	}
	string toString(){ return value.to!string; }
	ulong inv(ulong v){
		assert(v > 0);
		assert(v < mod);
		while(v >= _inv.length){
			_inv ~= _inv[mod % $] * (mod - mod / _inv.length) % mod;
		}
		return _inv[v];
	}
	ulong invvalue(){
		return inv(value);
	}
	static Finite opCall(ulong v){
		return Finite(v);
	}
	
}

// ---以下はユーティリティ--- //

// mod p における階乗
Finite perm(ulong x){
	static Finite[] _perm = [];
	if(_perm.length == 0) _perm ~= Finite(1);
	while(x >= _perm.length)
			_perm ~= _perm[$ - 1] * _perm.length;
	return _perm[x];
}

// mod p における階乗の逆元
Finite invperm(ulong x){
	static Finite[] _invperm = [];
	if(_invperm.length == 0) _invperm ~= Finite(1);
	while(x >= _invperm.length)
			_invperm ~= _invperm[$ - 1] / _invperm.length;
	return _invperm[x];
}

// mod p における二項係数（定義に注意：(a + b)! / a! / b! ）
Finite pascal(ulong a, ulong b){
	Finite res = perm(a + b) * invperm(a) * invperm(b);
	return res;
}


Measured memory_bytes: 2684