#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
char a[maxn], b[maxn], t[maxn];
int main() {
  int n;
  char c[1];
  scanf("%d", &n);
  gets(c);
  scanf("%s", a + 1);
  int d = 0;
  while (d <= n) {
    d++;
    if (n % d == 0) {
      for (int i = 1; i <= d; i++) {
        b[i] = a[d - i + 1];
      }
      for (int j = d + 1; j <= n; j++) {
        b[j] = a[j];
      }
      for (int i = 1; i <= n; i++) a[i] = b[i];
    }
  }
  for (int i = 1; i <= n; i++) printf("%c", b[i]);
  return 0;
}
