import std.stdio, std.conv, std.algorithm, std.string;
alias L = long;
L M = 998244353;
L[] X, D;
L q(L m, L[] U){
	foreach(i, u; U) if(i / m & 1 ^ U[i % m] ^ u) return u;
	return 1;
}
L t(L[] U){
	L f;
	foreach(u; U) f = (f * 2 + u) % M;
	return f;
}
void main(){
	L n = readln.chomp.to!L, b = n * 2;
	foreach(c; readln.chomp) X ~= c - '0';
	foreach_reverse(d; 3 .. n + 1) if(d % 2 && !(n % d)) D ~= d;
	
	L[L] C;
	foreach(d; D){
		C[d] = t(X[0 .. n / d]) + q(n / d, X);
		foreach(e; D) if(e > d && !(e % d)) C[d] += M - C[e];
		C[d] %= M;
	}
	
	n = (t(X) + 1) * b % M;
	foreach(d; D) n += M - C[d] * (b - b / d) % M;
	writeln(n % M);
}
