#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
int main() {
  long long int n, k, i, j;
  while (cin >> n) {
    vector<long long int> v;
    string t;
    cin >> t;
    for (i = 1; i <= sqrt(n); i++) {
      if (n % i == 0) {
        v.push_back(i);
        if (i * i != n) v.push_back(n / i);
      }
    }
    sort(v.begin(), v.end());
    for (i = 0; i < v.size(); i++) {
      long long int p = v[i];
      string t1;
      for (j = 0; j < p; j++) {
        t1.push_back(t[j]);
      }
      reverse(t1.begin(), t1.end());
      for (j = 0; j < p; j++) t[j] = t1[j];
    }
    cout << t << endl;
  }
  return 0;
}
