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 ^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; 0 .. 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(d; D) foreach(e; D) if(d - e) d % e || (C[e] -= C[d]);
	
	n = t(X) * b + b;
	foreach(d; D) n += M - C[d] * (b - b / d) % M;
	writeln(n % M);
}
