You are given a string s, consisting of small Latin letters. Let's denote the length of the string as |s|. The characters in the string are numbered starting from 1. 

Your task is to find out if it is possible to rearrange characters in string s so that for any prime number p ≤ |s| and for any integer i ranging from 1 to |s| / p (inclusive) the following condition was fulfilled sp = sp × i. If the answer is positive, find one way to rearrange the characters.

Input

The only line contains the initial string s, consisting of small Latin letters (1 ≤ |s| ≤ 1000).

Output

If it is possible to rearrange the characters in the string so that the above-mentioned conditions were fulfilled, then print in the first line "YES" (without the quotes) and print on the second line one of the possible resulting strings. If such permutation is impossible to perform, then print the single string "NO".

Examples

Input

abc


Output

YES
abc


Input

abcd


Output

NO


Input

xxxyxxx


Output

YES
xxxxxxy

Note

In the first sample any of the six possible strings will do: "abc", "acb", "bac", "bca", "cab" or "cba".

In the second sample no letter permutation will satisfy the condition at p = 2 (s2 = s4).

In the third test any string where character "y" doesn't occupy positions 2, 3, 4, 6 will be valid.

Difficulty: EASY
Tags: Number theory

Implementation

String algorithms

Starter code:

Solutions:
import math
ch = 'abcdefghijklmnopqrstuvwxyz'

def sieve(n):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
s = ['#'] + list(input())
lis = [0] * 26
n = len(s) - 1
prime = [True for i in range(1000 + 1)]
sieve(1000)
ans = [''] * (n + 1)
aa = []
aa.append(1)
for i in s[1:]:
	lis[ord(i) - ord('a')] += 1
for i in range(n // 2 + 1, n + 1, 1):
	if prime[i]:
		aa.append(i)
v = n - len(aa)
th = -1
for i in range(26):
	if lis[i] >= v:
		th = i
if th == -1:
	print('NO')
	exit()
for i in range(2, n + 1):
	if i not in aa:
		ans[i] = ch[th]
		lis[th] -= 1
j = 0
for i in aa:
	while j < 26 and lis[j] <= 0:
		j += 1
	ans[i] = ch[j]
	lis[j] -= 1
print('YES')
print(*ans[1:], sep='')


from collections import Counter
(d, t) = ('NO', input())
(c, n) = (Counter(t), len(t))
p = [0] * (n + 1)
for i in range(2, n // 2 + 1):
	if 1 - p[i]:
		p[i::i] = [1] * (n // i)
s = sum(p)
u = v = ''
for (q, k) in c.items():
	if v or k < s:
		u += q * k
	else:
		u += q * (k - s)
		v = q
if v:
	(d, j) = ('YES\n', 0)
	for i in range(1, n + 1):
		if p[i]:
			d += v
		else:
			d += u[j]
			j += 1
print(d)


S = input()
s = []
d = {}
n = 0
for i in S:
	if ord('a') <= ord(i) <= ord('z'):
		n += 1
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
primes = []
for i in range(max(3, n // 2 + 1), n + 1):
	j = 2
	f = 0
	while j * j <= i:
		if i % j == 0:
			f = 1
			break
		j += 1
	if not f:
		primes.append(i)
b = []
for i in d:
	b.append([d[i], i])
ans = ['' for i in range(n)]
b.sort()
for i in primes:
	ans[i - 1] = b[0][1]
	b[0][0] -= 1
	if b[0][0] == 0:
		b.pop(0)
if len(b) > 2 or (len(b) == 2 and b[0][0] != 1):
	print('NO')
else:
	print('YES')
	for i in ans:
		if i == '':
			print(b[0][1], end='')
			b[0][0] -= 1
			if b[0][0] == 0:
				b.pop(0)
		else:
			print(i, end='')


s = input().strip()
import math, functools, sys, heapq

@functools.lru_cache(None)
def check_prime(p):
	for i in range(2, int(math.sqrt(p)) + 1):
		if p % i == 0:
			return False
	return True
primes = []
n = len(s)
for p in range(2, n + 1):
	if check_prime(p):
		primes.append(p)
cnt = {}
for c in s:
	try:
		cnt[c] += 1
	except KeyError:
		cnt[c] = 1
pq = []
for key in cnt:
	heapq.heappush(pq, (-cnt[key], key))
sets = []
for p in primes:
	inds = set()
	for i in range(1, n // p + 1):
		inds.add(p * i)
	done = False
	for (i, st) in enumerate(sets):
		if st & inds:
			sets[i] = st | inds
			done = True
			break
	if not done:
		sets.append(inds)
sets.sort(key=lambda x: len(x), reverse=True)
ans = [None for _ in range(n)]
for st in sets:
	if not pq:
		print('NO')
		sys.exit()
	(cnt, c) = heapq.heappop(pq)
	if -cnt >= len(st):
		for i in st:
			ans[i - 1] = c
		cnt = -cnt - len(st)
		if cnt > 0:
			heapq.heappush(pq, (-cnt, c))
	else:
		print('NO')
		sys.exit()
i = 0
(cnt, c) = heapq.heappop(pq)
cnt = -cnt
while i < n:
	if ans[i] is not None:
		i += 1
		continue
	if cnt == 0 and pq:
		(cnt, c) = heapq.heappop(pq)
		cnt = -cnt
	ans[i] = c
	cnt -= 1
	i += 1
print('YES')
print(''.join(ans))


s = input()
n = len(s)
numbers = [1 for i in range(n + 1)]
numbers[0] = 0
numbers[1] = 0
for i in range(2, n + 1):
	if numbers[i] == 1:
		j = 2
		while j * i <= n:
			numbers[j * i] = 0
			j += 1
primes = [1]
for x in range(n + 1):
	if numbers[x] == 1:
		primes.append(x)
memo = {}
for char in s:
	try:
		memo[char] += 1
	except KeyError:
		memo[char] = 1
memo = [[key] * value for (key, value) in memo.items()]
memo.sort(key=len, reverse=True)
max_equals = memo[0]
memo.pop(0)
output = [None for _ in range(n + 1)]
equals_needed = 0
for i in range(1, len(primes)):
	if primes[i] * 2 <= n:
		equals_needed += 1
primes.pop(0)
answer = True
for i in range(equals_needed):
	prime = primes[i]
	j = 1
	while primes[i] * j <= n:
		try:
			idx = prime * j
			if not output[idx]:
				output[idx] = max_equals[0]
				max_equals.pop(0)
		except IndexError:
			answer = False
			break
		j += 1
if not answer:
	print('NO')
else:
	left = max_equals
	for ls in memo:
		left += ls
	j = 0
	for i in range(1, n + 1):
		if not output[i]:
			output[i] = left[j]
			j += 1
	final_answer = ''.join(output[1:])
	print('YES')
	print(final_answer)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
s = input()
n = len(s)
A = [i for i in range(n + 1)]

def par(x):
	if A[x] == x:
		return x
	return par(A[x])

def union(x, y):
	u = par(x)
	v = par(y)
	if u == v:
		return
	if u < v:
		A[v] = u
	else:
		A[u] = v
for i in range(2, n + 1):
	if A[i] != i:
		continue
	for j in range(2 * i, n + 1, i):
		union(i, j)
d = {}
for i in range(1, n + 1):
	d[A[i]] = d.get(A[i], 0) + 1
cnt = {}
for c in s:
	cnt[c] = cnt.get(c, 0) + 1
B1 = [[d[i], i] for i in d]
B2 = [[cnt[i], i] for i in cnt]
B1.sort(reverse=True)
B2.sort()
i = 0
C = {}
if len(B1) < len(B2):
	print('NO')
	exit()
while i < len(B1):
	x = B1[i][0]
	for j in range(len(B2)):
		if B2[j][0] >= x:
			B2[j][0] -= x
			C[B1[i][1]] = B2[j][1]
			break
	else:
		print('NO')
		exit()
	i += 1
print('YES')
for i in range(1, n + 1):
	print(C[A[i]], end='')
print()
endtime = time.time()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def primeN(n):
	prime = [True for i in range(n + 1)]
	prime[0] = False
	prime[1] = False
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return [p for p in range(n + 1) if prime[p]]
s = input()
n = len(s)
primes = primeN(n)
C = Counter(s)
ans = ['' for i in range(n)]
have = {}
for i in primes:
	have[i] = n // i
moreThanOne = []
need = set()
for p in have:
	if have[p] > 1:
		moreThanOne.append(p)
		for i in range(p - 1, n, p):
			need.add(i)
need = len(need)
ok = False
for i in C:
	if C[i] >= need:
		ok = True
		ele = i
		C[i] -= need
		break
if not ok:
	print('NO')
	exit()
print('YES')
for p in moreThanOne:
	for i in range(p - 1, n, p):
		ans[i] = ele
rem = list(set(s))
ind = 0
for i in range(n):
	if ans[i] == '':
		while C[rem[ind]] == 0:
			ind += 1
		ans[i] = rem[ind]
		C[rem[ind]] -= 1
print(*ans, sep='')


from collections import Counter
from sys import stdin
s = stdin.readline()[:-1]
(n, c) = (len(s), Counter(s))
(cnt, b) = max(((c[k], k) for k in c))
isPrime = [True] * (n + 1)
(isPrime[0], isPrime[1]) = (False, False)
for i in range(2, n + 1):
	if isPrime[i]:
		for j in range(2 * i, n + 1, i):
			isPrime[j] = False
free = 1 + sum(isPrime[n // 2 + 1:])
if n <= 3:
	print('YES')
	print(s)
elif cnt < n - free:
	print('NO')
else:
	print('YES')
	ans = [b] * (n + 1)
	ans[0] = ''
	c[b] = 0
	m = False
	j = n // 2 + 1
	for key in c.elements():
		while j <= n:
			if isPrime[j]:
				break
			j += 1
		else:
			m = True
			break
		ans[j] = key
		j += 1
	if m:
		ans[1] = key
	print(''.join(ans))


import bisect
s = input()
b = sorted(s)
n = len(s)
ch = []
ct = []
i = 0
while i < n:
	t = b[i]
	c = 0
	while t == b[i]:
		c = c + 1
		i = i + 1
		if i == n:
			break
	ch.append([c, t])
	ct.append(c)
q = len(ct)
ct.sort()
ch.sort()
color = [1, 1] + [0] * (n - 1)
p = []
x = [0] * (n + 1)
for i in range(2, n + 1):
	if x[i] == 0:
		for j in range(2 * i, n + 1, i):
			x[j] = 1
for i in range(2, n + 1):
	if x[i] == 0:
		p.append(i)
for i in p:
	co = i
	for j in range(i, n + 1, i):
		if color[j]:
			co = color[j]
			break
	for j in range(i, n + 1, i):
		color[j] = co
dc = {}
for i in range(1, n + 1):
	dc[color[i]] = dc.get(color[i], 0) + 1
ans = [' '] * (n + 1)
f = 0
for i in range(1, n + 1):
	if ans[i] == ' ':
		j = bisect.bisect_left(ct, dc[color[i]])
		if j == q:
			f = 1
			break
		else:
			char = ch[j][1]
			for z in range(i, n + 1):
				if color[z] == color[i]:
					ans[z] = char
			ct[j] = ct[j] - dc[color[i]]
			ch[j][0] = ch[j][0] - dc[color[i]]
			ct.sort()
			ch.sort()
if f:
	print('NO')
else:
	print('YES')
	s = ''
	for i in range(1, n + 1):
		s = s + ans[i]
	print(s)


s = input()
d = dict()
for c in s:
	if c not in d:
		d[c] = 0
	d[c] += 1
cnto = 1
isprime = [True] * (len(s) + 1)
for p in range(2, len(s) + 1):
	if isprime[p]:
		for i in range(p * p, len(s) + 1, p):
			isprime[i] = False
for i in range(1, len(s) + 1):
	if i > len(s) // 2 and isprime[i]:
		cnto += 1
cnto = len(s) - cnto
if max(d.values()) < cnto:
	print('NO')
else:
	print('YES')
	m = max(d.values())
	for (c, v) in d.items():
		if v == m:
			d[c] -= cnto
			mc = c
			break
	ans = []
	buf = []
	for (c, v) in d.items():
		for i in range(v):
			buf.append(c)
	for i in range(1, len(s) + 1):
		if i == 1 or (i > len(s) // 2 and isprime[i]):
			ans.append(buf[-1])
			buf.pop()
		else:
			ans.append(mc)
	print(''.join(ans))


def prime(a):
	i = 2
	while i * i <= a:
		if a % i == 0:
			return False
		i += 1
	return True
tab = list(input())
letter_count = {}
for letter in tab:
	if letter in letter_count:
		letter_count[letter] += 1
	else:
		letter_count[letter] = 1
max_amount_letter = 'a'
max_amount = 0
for (letter, amount) in letter_count.items():
	if max_amount < amount:
		max_amount = amount
		max_amount_letter = letter
good_prime = [False for i in range(len(tab))]
good_prime[0] = True
for n in range((len(tab) + 2) // 2, len(tab) + 1):
	good_prime[n - 1] = prime(n)
if max_amount >= good_prime.count(False):
	print('YES')
	letter_count[max_amount_letter] = 0
	for i in range(len(good_prime)):
		if good_prime[i] == False:
			good_prime[i] = max_amount_letter
			max_amount -= 1
	for i in range(len(good_prime)):
		if good_prime[i] == True and max_amount > 0:
			good_prime[i] = max_amount_letter
			max_amount -= 1
	i = 0
	for (letter, amount) in letter_count.items():
		for a in range(amount):
			while good_prime[i] != True:
				i += 1
			good_prime[i] = letter
			i += 1
	print(''.join(good_prime))
else:
	print('NO')


s = input()
if len(s) == 1:
	exit(print('YES\n' + s))
(d, ans, sieve) = ({}, [0] * len(s), [0] * 1005)
for i in s:
	d[i] = d.get(i, 0) + 1
for i in range(2, len(s) + 1):
	if not sieve[i]:
		for j in range(i * i, 1005, i):
			sieve[j] = 1
mx = max(d, key=lambda x: d[x])
for j in range(2, len(s) // 2 + 1):
	ans[j - 1] = mx
	d[mx] -= 1
if d[mx] < 0:
	exit(print('NO'))
for i in range(len(s) // 2 + 1, len(s) + 1):
	if not sieve[i]:
		mx = max(d, key=lambda x: d[x] and x != ans[1])
		if not d[mx]:
			mx = ans[1]
		ans[i - 1] = mx
		d[mx] -= 1
	else:
		ans[i - 1] = ans[1]
		d[ans[1]] -= 1
	if d[mx] < 0 or d[ans[1]] < 0:
		exit(print('NO'))
print('YES')
mx = max(d, key=lambda x: d[x])
print(mx + ''.join(ans[1:]))


import sys
import math
from collections import defaultdict
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65

def getInt():
	return int(sys.stdin.readline().rstrip())

def getInts():
	return map(int, sys.stdin.readline().rstrip().split(' '))

def getString():
	return sys.stdin.readline().rstrip()

def printOutput(ans):
	sys.stdout.write()
	pass

def getPrimes(s):
	primes = [2]
	MAX = s + 1
	for i in range(3, MAX):
		STOP = math.ceil(math.sqrt(i) + 1)
		isPrime = True
		for j in range(2, STOP):
			if i % j == 0:
				isPrime = False
		if isPrime:
			primes.append(i)
	return primes

def solve(let, s):
	primes = getPrimes(len(s))
	bigindices = []
	oneIndices = []
	ones = 0
	for i in primes:
		k = len(s) // i
		if k > 1:
			bigindices.append(i)
		if k == 1:
			oneIndices.append(i)
			ones += 1
	solution = [0 for _ in range(len(s))]
	bigK = max(let, key=lambda x: let[x])
	total = 0
	for index in bigindices:
		for i in range(index, len(solution) + 1, index):
			if solution[i - 1] == 0:
				solution[i - 1] = bigK
				total += 1
	if total > let[bigK]:
		return ('NO', None)
	else:
		let[bigK] -= total
	for item in oneIndices:
		for (key, val) in let.items():
			if val >= 1:
				let[key] -= 1
				ones -= 1
				solution[item - 1] = key
				break
	if ones != 0:
		return ('NO', None)
	for i in range(len(solution)):
		if solution[i] == 0:
			for (key, val) in let.items():
				if val > 0:
					val -= 1
					solution[i] = key
					break
	return ('YES', ''.join(solution))

def readinput():
	lettercount = defaultdict(int)
	string = getString()
	for ele in string:
		lettercount[ele] += 1
	ans = solve(lettercount, string)
	print(ans[0])
	if ans[0] != 'NO':
		print(ans[1])
readinput()


from sys import stdin, stdout
from collections import Counter

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	outputs = []
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			outputs.append(p)
	return outputs

def main():
	s = stdin.readline().strip()
	condn = False
	r_s = ''
	if len(s) <= 2:
		condn = True
		r_s = s
	else:
		d = Counter(s)
		k_s = sorted(d.keys(), key=lambda key: d[key], reverse=True)
		primes = SieveOfEratosthenes(len(s))
		x = [(1, 0)]
		addn = 0
		for (j, i) in enumerate(primes):
			if j + 1 < len(primes):
				next = primes[j + 1]
			else:
				next = len(s)
			if len(s) // i > 1:
				x.append((next - i, 1))
				addn += next - i
			else:
				x.append((1, 0))
				if next == len(s) and j + 1 == len(primes):
					char = next - i
					addn += char
				else:
					char = next - i - 1
					addn += char
				if char:
					x.append((char, 1))
		if addn > d[k_s[0]]:
			condn = False
		else:
			condn = True
			(l, r) = (0, len(k_s) - 1)
			r_s = ''
			i = 0
			while i < len(x) and l <= r:
				if x[i][1] == 1:
					r_s += k_s[l] * x[i][0]
					d[k_s[l]] -= x[i][0]
				else:
					r_s += k_s[r] * x[i][0]
					d[k_s[r]] -= x[i][0]
				if d[k_s[r]] <= 0:
					r -= 1
				i += 1
	if condn:
		print('YES')
		print(r_s)
	else:
		print('NO')
main()


from collections import Counter
is_prime = lambda x: all((x % d for d in range(2, int(x ** 0.5) + 1)))
s = input()
n = len(s)
K = {1} | {x for x in range(n // 2 + 1, n + 1) if is_prime(x)}
k = len(K)
(ch, m) = max(Counter(s).items(), key=lambda x: x[1])
if m + k < n:
	print('NO')
else:
	print('YES')
	s = list(s.replace(ch, '', n - k))
	A = [0] * n
	for i in range(n):
		A[i] = s.pop() if i + 1 in K else ch
	print(''.join(A))


import sys
from collections import Counter
s = input()
counts = Counter(s)
common = counts.most_common()
common.reverse()
n = len(s)
out = ['0'] * (n + 1)
for p in range(2, n + 1):
	if out[p] != '0':
		continue
	filled = False
	count = 0
	for i in range(p, n + 1, p):
		if out[i] != '0':
			filled = out[i]
			break
		count += 1
	if not filled:
		for (l, c) in counts.most_common():
			if c >= count:
				break
		counts[l] -= count
		if counts[l] < 0:
			print('NO')
			sys.exit()
		for i in range(p, n + 1, p):
			out[i] = l
	else:
		for i in range(p, n + 1, p):
			if out[i] == '0':
				out[i] = filled
				counts[filled] -= 1
				if counts[filled] < 0:
					print('NO')
					sys.exit()
for (l, count) in counts.most_common():
	if count == 1:
		out[1] = l
print('YES')
print(''.join(out[1:]))


p = [1] * 1001
for i in range(2, 1001):
	if p[i]:
		for j in range(i, 1001, i):
			p[j] = 0
		p[i] = 1
a = input()
z = len(a)
l = [0] * 26
for i in a:
	l[ord(i) - 97] += 1
gh = 0
for i in range(z // 2 + 1, z + 1):
	gh += p[i]
if max(l) < z - 1 - gh:
	exit(print('NO'))
ans = [''] * (z + 1)
t = l.index(max(l))
for i in range(2, 1 + z // 2):
	ans[i] = chr(t + 97)
	l[t] -= 1
for i in range(1 + z // 2, z + 1):
	if p[i] == 0:
		ans[i] = chr(t + 97)
		l[t] -= 1
j = 0
for i in range(1, z + 1):
	if ans[i] == '':
		while l[j] <= 0:
			j += 1
		ans[i] = chr(j + 97)
		l[j] -= 1
print('YES')
print(''.join(ans[1:]))


import os, io
from sys import stdout
import collections
import random
import math
from operator import itemgetter
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter

def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def powerOfK(k, max):
	if k == 1:
		return [1]
	if k == -1:
		return [-1, 1]
	result = []
	n = 1
	while n <= max:
		result.append(n)
		n *= k
	return result

def prefixSum(arr):
	for i in range(1, len(arr)):
		arr[i] = arr[i] + arr[i - 1]
	return arr

def divisors(n):
	i = 1
	result = []
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				result.append(i)
			else:
				result.append(i)
				result.append(n / i)
		i += 1
	return result
s = input().decode('utf-8').strip()
c = Counter(s)
dp = [0] * len(s)
primes = primes(len(s) + 1)
components = []
for p in primes:
	l = []
	for i in range(p, len(s) + 1, p):
		l.append(i)
	for comp in components:
		if len(list(set(comp) & set(l))):
			comp += l
			break
	else:
		if len(l):
			components.append(l)
need = []
for comp in components:
	need.append(len(set(comp)))
import heapq
heap = []
for (e, v) in c.items():
	heapq.heappush(heap, (-v, e))
result = [''] * len(s)
for comp in components:
	(i, letter) = heapq.heappop(heap)
	i = -i
	indexes = set(comp)
	if i >= len(indexes):
		heapq.heappush(heap, (-(i - len(indexes)), letter))
		for index in set(comp):
			result[index - 1] = letter
	else:
		print('NO')
		break
else:
	while len(heap):
		(i, letter) = heapq.heappop(heap)
		for j in range(len(result)):
			if i == 0:
				break
			if result[j] == '':
				result[j] = letter
				i -= 1
	print('YES')
	print(''.join(result))


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	s = si()
	n = len(s)
	par = [i for i in range(n + 1)]

	def find(u):
		if par[u] == u:
			return u
		par[u] = find(par[u])
		return par[u]

	def merge(u, v):
		u = find(u)
		v = find(v)
		if u != v:
			if u < v:
				(u, v) = (v, u)
			par[u] = v
	ok = [0] * (n + 1)
	for i in range(2, n + 1):
		if ok[i] == 0:
			for j in range(2 * i, n + 1, i):
				ok[j] = 1
				merge(i, j)
	m = {}
	mx = 0
	idx = 0
	for i in range(1, n + 1):
		if par[i] not in m:
			m[par[i]] = 0
		m[par[i]] += 1
		if mx < m[par[i]]:
			mx = m[par[i]]
			idx = par[i]
	m1 = {}
	mx1 = 0
	c = 'a'
	for i in s:
		if i not in m1:
			m1[i] = 0
		m1[i] += 1
		if mx1 < m1[i]:
			mx1 = m1[i]
			c = i
	if mx > mx1:
		print('NO')
		return
	res = ['0'] * n
	for i in range(1, n + 1):
		if par[i] == idx:
			res[i - 1] = c
	x = []
	for i in m1:
		if i == c:
			rem = m1[i] - m[idx]
			for j in range(rem):
				x.append(i)
		else:
			for j in range(m1[i]):
				x.append(i)
	for i in range(n):
		if res[i] == '0':
			res[i] = x[-1]
			x.pop()
	print('YES')
	print(''.join(res))
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	return prime
s = input()
primes = SieveOfEratosthenes(len(s))
length = len(s)
unique = set()
unique.add(1)
for i in range(2, len(s) + 1):
	if primes[i] and 2 * i > length:
		unique.add(i)
count = dict()
sameHave = 1
sameC = s[0]
for c in s:
	if c not in count:
		count[c] = 1
	else:
		count[c] += 1
		if count[c] > sameHave:
			sameHave = count[c]
			sameC = c
uniqueList = []
for char in s:
	if char != sameC:
		uniqueList.append(char)
sameNeed = length - len(unique)
if sameHave >= sameNeed:
	print('YES')
	out = ''
	for i in range(1, len(s) + 1):
		if i in unique:
			if len(uniqueList) != 0:
				out += uniqueList.pop()
			else:
				out += sameC
		else:
			out += sameC
	print(out)
else:
	print('NO')


from collections import Counter

def is_prime(x):
	if x < 2:
		return 0
	for i in range(2, x):
		if x % i == 0:
			return False
	return True

def proc(s):
	n = len(s)
	same = set()
	for p in range(2, n + 1):
		if not is_prime(p):
			continue
		if p * 2 > n:
			continue
		for i in range(2, n // p + 1):
			same.add(p * i)
		same.add(p)
	counter = Counter(s)
	(ch, count) = counter.most_common(1)[0]
	if count < len(same):
		print('NO')
		return
	same = [x - 1 for x in same]
	w = [x for x in s]
	for i in same:
		if w[i] == ch:
			continue
		for j in range(n):
			if j not in same and w[j] == ch:
				tmp = w[j]
				w[j] = w[i]
				w[i] = tmp
				break
	print('YES')
	print(''.join(w))
s = input()
proc(s)


k = [1] * 1001
for i in range(2, 1001):
	if k[i] == 1:
		z = i
		for j in range(z, 1001, z):
			k[j] = 0
		k[i] = 1
k[0] = k[1] = 0
z = input()
lo = len(z)
if 1:
	w = [0] * 26
	for i in z:
		w[ord(i) - 97] += 1
	p = 0
	for i in range(lo // 2 + 1, lo + 1):
		p += k[i]
	if max(w) < lo - p - 1:
		print('NO')
	else:
		print('YES')
		s = [1] * (lo + 1)
		k1 = w.index(max(w))
		for i in range(2, lo // 2 + 1):
			s[i] = chr(k1 + 97)
			w[k1] -= 1
		for i in range(lo // 2 + 1, lo + 1):
			if k[i] == 0 and w[k1] != 0:
				s[i] = chr(k1 + 97)
				w[k1] -= 1
		j = 0
		for i in range(1, 1 + lo):
			if s[i] == 1:
				while w[j] < 1:
					j += 1
				s[i] = chr(97 + j)
				w[j] -= 1
		print(*s[1:], sep='')


import sys
n = 1001
temp = [True for i in range(n + 1)]
(temp[0], temp[1]) = (False, False)
for i in range(2, int(n ** 0.5) + 1):
	if temp[i] == True:
		for j in range(i * 2, n + 1, i):
			temp[j] = False
s = input()
se = set()
se.add(1)
n = len(s)
for i in range(2, n + 1):
	if temp[i] == True and 2 * i > n:
		se.add(i)
d = {}
(maxi, letter) = (0, 0)
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	if d[i] > maxi:
		maxi = d[i]
		letter = i
same_letters = n - len(se)
if same_letters > maxi:
	print('NO')
	exit()
ans = ''
d[letter] -= same_letters
for i in range(1, 1 + n):
	if i not in se:
		ans += letter
	else:
		for j in d:
			if d[j] > 0:
				ans += j
				d[j] -= 1
				break
print('YES')
print(ans)