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.

Source: codeforces | Difficulty: EASY
Tags: Number theory

Implementation

String algorithms


Solutions:
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()


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='')


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='')


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)


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 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 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)


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='')


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()


def h(s, k):
	res = ''
	for i in s:
		if i != k:
			res += i
	return res

def ans(s, k, times, Pr: list):
	d = h(s, k)
	j = 0
	res = ''
	cc = 0
	for i in range(len(s)):
		if i + 1 not in Pr:
			res += k
			cc += 1
		elif j < len(d):
			res += d[j]
			j += 1
		else:
			res += k
	return res

def ans1(s, k, times, Pr: list):
	d = h(s, k)
	res = ''
	res += d[0]
	j = 1
	for i in range(len(s) - 1):
		if i + 2 not in Pr:
			res += k
		elif j < len(d):
			res += d[j]
			j += 1
		else:
			res += k
	return res

def isprime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def getprimes(n):
	res = []
	for i in range(2, n + 1):
		if isprime(i):
			res.append(i)
	return res
s = input()
A = []
Primes = getprimes(len(s))

def f(A: list, l):
	res = 0
	resPr = []
	for i in A:
		if i > l // 2:
			res += 1
			resPr.append(i)
	return (res, resPr)
(g, Pr) = f(Primes, len(s))
Dict = dict()
for i in s:
	if i in Dict:
		Dict[i] += 1
	else:
		Dict[i] = 1
for (k, v) in Dict.items():
	if v >= len(s) - g:
		print('YES')
		print(ans(s, k, len(s) - g, Pr), end='')
		exit()
	elif v == len(s) - g - 1:
		print('YES')
		print(ans1(s, k, len(s) - g, Pr), end='')
		exit()
print('NO')


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))