#include void chmax(int *a, int b) { if (*a < b) *a = b; } int main() { char S[2000001]; scanf("%s", S); int i, j, l, n, tmp, max, argmax, min, argmin, num[26]; for (n = 0; S[n] != 0; n++); for (l = 1, min = n; l <= n / 2; l++) { if (n % l != 0) continue; for (i = 0, tmp = 0; i < l; i++) { for (j = 0; j < 26; j++) num[j] = 0; for (j = i; j < n; j += l) num[S[j]-'A']++; for (j = 0, max = 0; j < 26; j++) chmax(&max, num[j]); tmp += max; } if (min > n - tmp) { min = n - tmp; argmin = l; } } l = argmin; for (i = 0; i < l; i++) { for (j = 0; j < 26; j++) num[j] = 0; for (j = i; j < n; j += l) num[S[j]-'A']++; for (j = 0, max = 0; j < 26; j++) { if (max < num[j]) { max = num[j]; argmax = j; } } for (j = i; j < n; j += l) S[j] = 'A' + argmax; } printf("%s\n", S); fflush(stdout); return 0; }