R=range S=input() N=len(S) L=1415 P=[] C=[0]*L for i in R(2,L): if C[i]<1: P+=[i];j=i*i while j1:D+=[d*n for d in D[-r:]];r*=2;E+=[[n,1]];e=e//n*(n-1) D.pop() d_best = -1 opt = N + 1 for d in D: Nd = N // d opt_temp = 0 for i in R(d): h = [0]*26 temp = 0 for j in R(Nd): c = ord(S[i+j*d]) - ord('A') h[c] += 1 temp = max( temp , h[c] ) opt_temp += Nd - temp if opt > opt_temp: opt = opt_temp d_best = d Nd = N // d_best T=['A']*N for i in R(d_best): h = [0]*26 for j in R(Nd):h[ord(S[i+j*d_best]) - ord('A')] += 1 c_opt = -1 temp = 0 for c in R(26): if temp < h[c]: temp = h[c] c_opt = c for j in R(Nd):T[i+j*d_best] = chr(c_opt + ord('A')) print("".join(T))