#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << endl
template <class T>
using VV = vector<vector<T>>;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;
#pragma endregion

map<ll, ll> factorize(ll x) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= x; ++i) {
    while (x % i == 0) {
      ++res[i];
      x /= i;
    }
  }
  if (x != 1) {
    ++res[x];
  }
  return res;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, map<T, S>& ma) {
  os << "[";
  for (auto itr = ma.begin(); itr != ma.end(); ++itr) {
    cout << "key: " << itr->first << " , val: " << itr->second << "\n ";
  }
  os << "]";
  return os;
}

const ll mod = 998244353;

string tostring(ll i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> div;
  for (int i = 1; i <= N; i += 2)
    if (N % i == 0) div.pb(i);
  string S;
  cin >> S;
  int sz = div.size();
  vector<ll> co(sz);
  rep(i, sz) {
    ll block = div[i];
    ll len = N / block;
    string head = S.substr(0, len);
    string head_rev = head;
    replace(all(head_rev), '0', '2');
    replace(all(head_rev), '1', '0');
    replace(all(head_rev), '2', '1');
    ll headnum = 0;
    rep(j, len) {
      headnum *= 2;
      headnum = headnum % mod;
      headnum += (S[j] - '0');
    }
    string sub;
    for (int j = 0; j < block; ++j) {
      sub = S.substr(len * j, len);
      if (j % 2 == 0) {
        if (head > sub) {
          break;
        } else if (head < sub) {
          ++headnum;
          break;
        }
      } else {
        if (head_rev > sub) {
          break;
        } else if (head_rev < sub) {
          ++headnum;
          break;
        }
      }
      if (j == block - 1) {
        ++headnum;
        break;
      }
    }
    co[i] = headnum % mod;
  }

  for (int i = sz - 1; i >= 0; --i) {
    for (int j = 0; j < i; ++j) {
      if (div[i] % div[j] == 0) {
        co[j] -= co[i];
      }
    }
  }
  ll ans = 0;
  rep(i, sz) {
    ans += 2 * N / div[i] * co[i];
    ans = ans % mod;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1160