#include <bits/stdc++.h>
using namespace std;
vector<int> fac;
void factor(int n, int m) {
  if (m * m == n) {
    fac.push_back(m);
    return;
  } else if (m * m > n) {
    return;
  }
  if (n % m == 0) {
    fac.push_back(m);
    factor(n, m + 1);
    fac.push_back(n / m);
  } else {
    factor(n, m + 1);
  }
}
int main() {
  int n;
  cin >> n;
  string str;
  cin >> str;
  factor(n, 1);
  for (vector<int>::iterator it = fac.begin(); it != fac.end(); it++) {
    reverse(str.begin(), str.begin() + *it);
  }
  cout << str << endl;
}
