#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  string s, p, r;
  s = "1";
  cin >> p;
  s = s + p;
  for (long long int i = 2; i < n - 1; i++) {
    if (n % i == 0) {
      p = s.substr(1, i);
      s = s.substr(i + 1, n);
      reverse(p.begin(), p.end());
      s = "1" + p + s;
    }
  }
  s = s.substr(1, n);
  reverse(s.begin(), s.end());
  cout << s << endl;
}
