#include <bits/stdc++.h>
using namespace std;
int d[100];
string s;
bool cmp(int a, int b) { return a < b; }
string solve(string &s, int n) {
  int start = 0;
  int end = n - 1;
  while (start < end) {
    swap(s[start], s[end]);
    start++;
    end--;
  }
  return s;
}
int main() {
  int n, k = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      d[k] = i;
      k++;
    }
  }
  sort(d, d + k, cmp);
  cin >> s;
  for (int i = 0; i < k; i++) {
    s = solve(s, d[i]);
  }
  cout << s << endl;
}
