#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = 1; i < n + 1; ++i) {
    if (n % i) continue;
    reverse(s.begin(), s.begin() + i);
    cerr << s << '\n';
  }
  cout << s;
}
