#include <bits/stdc++.h>
using namespace std;
char s[100], s1[100];
int n, d;
int a[100];
void devisor() {
  for (int i = 1; i <= n; i++)
    if (n % i == 0) {
      d++;
      a[d] = i;
    }
}
void reverseS(int m) {
  strcpy(s1, s);
  for (int i = 0; i <= m - 1; i++) s1[i] = s[m - 1 - i];
  strcpy(s, s1);
}
int main() {
  cin >> n;
  cin >> s;
  d = 0;
  devisor();
  for (int i = 1; i <= d; i++) reverseS(a[i]);
  cout << s;
  return 0;
}
