R=range S=input() N=len(S) P=[];n=N for i in R(2,int(n**0.5)+1): c=0 while n%i<1:n//=i;c=1 if c:P+=[i] if n>1:P+=[n] opt = N + 1 for p in P: d = N // p opt_temp = 0 for i in R(d): h = [0]*26 temp = 0 for j in R(p): c = ord(S[i+j*d]) - ord('A') h[c] += 1 temp = max( temp , h[c] ) opt_temp += p - temp if opt > opt_temp: opt = opt_temp p_best = p d = N // p_best T=['A']*N for i in R(d): h = [0]*26 for j in R(p_best):h[ord(S[i+j*d]) - 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(p_best):T[i+j*d] = chr(c_opt + ord('A')) print("".join(T))