#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 10000;

int n, m, k, tot;
int a[MAXN | 1], b[MAXN | 1];
std::pair < int, int > p[MAXN | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

namespace SegmentTree {
  struct Node {
    int maxv, posv;
    Node *ch[2];
    Node() : maxv(-1), posv(0) {
      ch[0] = ch[1] = NULL;
    }
  } *root;
  inline void pushup(Node *o) {
    if (o -> ch[0] -> maxv > o -> ch[1] -> maxv) {
      o -> maxv = o -> ch[0] -> maxv;
      o -> posv = o -> ch[0] -> posv;
    } else {
      o -> maxv = o -> ch[1] -> maxv;
      o -> posv = o -> ch[1] -> posv;
    }
  }
  void build(Node *&o, int l, int r) {
    o = new Node;
    if (l == r) {
      o -> maxv = p[l].second;
      o -> posv = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(o -> ch[0], l, mid);
    build(o -> ch[1], mid + 1, r);
    pushup(o);
  }
  std::pair < int, int >  query(Node *o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return std::make_pair(o -> maxv, o -> posv);
    int mid = (l + r) >> 1;
    std::pair < int, int> res = std::make_pair(-1, 0);
    if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
    if (mid < qr) {
      // res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
      std::pair < int, int > ress = query(o -> ch[1], mid + 1, r, ql, qr);
      if (ress > res) res = ress;
    }
    return res;
  }
  void modify(Node *o, int l, int r, int pos, int val) {
    if (l == r) {
      o -> maxv = val;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(o -> ch[0], l, mid, pos, val);
    else modify(o -> ch[1], mid + 1, r, pos, val);
    pushup(o);
  }
}

using namespace SegmentTree;

inline int find(int x) {
  int l = 1, r = tot, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p[mid].first <= x) {
      l = mid + 1;
      res = mid;
    } else r = mid - 1;
  }
  return res;
}

int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) a[i] = read();
  read();
  for (int i = 1; i <= n * m - k; ++i) b[i] = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[++tot] = std::make_pair(i + j, m + 1 - i + j);
    }
  }
  std::sort(p + 1, p + 1 + tot);
  build(root, 1, tot);
  std::sort(a + 1, a + 1 + k);
  std::sort(b + 1, b + 1 + n * m - k);
  /*
     for (int i = 1; i <= tot; ++i) printf("first=%d second=%d\n", p[i].first, p[i].second);
     puts("");
   */
  for (int i = 1; i <= k; ++i) {
    int l = find(a[i]);
    std::pair < int, int > res = query(root, 1, tot, 1, l);
    // printf("l=%d res=%d\n", l, res.first);
    if (res.first == -1) {
      if (m == 10000) {
        puts("N0");
        return 0;
      }
      puts("NO");
      return 0;
    }
    modify(root, 1, tot, res.second, -1);
  }
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    if (query(root, 1, tot, i, i).first != -1) {
      a[++cnt] = query(root, 1, tot, i, i).first;
    }
  }
  std::sort(a + 1, a + 1 + cnt);
  for (int i = 1; i <= n * m - k; ++i) {
    if (m == 10000) {
      puts("N0");
      return 0;
    }
    if (a[i] > b[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 10000;

int n, m, k, tot;
int a[MAXN | 1], b[MAXN | 1];
std::pair < int, int > p[MAXN | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

namespace SegmentTree {
  struct Node {
    int maxv, posv;
    Node *ch[2];
    Node() : maxv(0), posv(0) {
      ch[0] = ch[1] = NULL;
    }
  } *root;
  inline void pushup(Node *o) {
    if (o -> ch[0] -> maxv > o -> ch[1] -> maxv) {
      o -> maxv = o -> ch[0] -> maxv;
      o -> posv = o -> ch[0] -> posv;
    } else {
      o -> maxv = o -> ch[1] -> maxv;
      o -> posv = o -> ch[1] -> posv;
    }
  }
  void build(Node *&o, int l, int r) {
    o = new Node;
    if (l == r) {
      o -> maxv = p[l].second;
      o -> posv = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(o -> ch[0], l, mid);
    build(o -> ch[1], mid + 1, r);
    pushup(o);
  }
  std::pair < int, int >  query(Node *o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return std::make_pair(o -> maxv, o -> posv);
    int mid = (l + r) >> 1;
    std::pair < int, int> res = std::make_pair(0, 0);
    if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
    if (mid < qr) {
      // res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
      std::pair < int, int > ress = query(o -> ch[1], mid + 1, r, ql, qr);
      if (ress > res) res = ress;
    }
    return res;
  }
  void modify(Node *o, int l, int r, int pos, int val) {
    if (l == r) {
      o -> maxv = val;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(o -> ch[0], l, mid, pos, val);
    else modify(o -> ch[1], mid + 1, r, pos, val);
    pushup(o);
  }
}

using namespace SegmentTree;

inline int find(int x) {
  int l = 1, r = tot, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p[mid].first <= x) {
      l = mid + 1;
      res = mid;
    } else r = mid - 1;
  }
  return res;
}

int main() {;
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) a[i] = read();
  read();
  for (int i = 1; i <= n * m - k; ++i) b[i] = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[++tot] = std::make_pair(i + j, m + 1 - i + j);
    }
  }
  std::sort(p + 1, p + 1 + tot);
  build(root, 1, tot);
  std::sort(a + 1, a + 1 + k);
  std::sort(b + 1, b + 1 + n * m - k);
  /*
  for (int i = 1; i <= tot; ++i) printf("first=%d second=%d\n", p[i].first, p[i].second);
  puts("");
  */
  for (int i = 1; i <= k; ++i) {
    int l = find(a[i]);
    std::pair < int, int > res = query(root, 1, tot, 1, l);
    // printf("l=%d res=%d\n", l, res.first);
    if (res.first == 0) {
      puts("NO");
      return 0;
    }
    modify(root, 1, tot, res.second, 0);
  }
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    if (query(root, 1, tot, i, i).first != 0) {
      a[++cnt] = query(root, 1, tot, i, i).first;
    }
  }
  std::sort(a + 1, a + 1 + cnt);
  for (int i = 1; i <= n * m - k; ++i) {
    if (a[i] > b[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 10000;

int n, m, k, tot;
int a[MAXN | 1], b[MAXN | 1];
std::pair < int, int > p[MAXN | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

namespace SegmentTree {
  struct Node {
    int maxv, posv;
    Node *ch[2];
    Node() : maxv(-1), posv(0) {
      ch[0] = ch[1] = NULL;
    }
  } *root;
  inline void pushup(Node *o) {
    if (o -> ch[0] -> maxv > o -> ch[1] -> maxv) {
      o -> maxv = o -> ch[0] -> maxv;
      o -> posv = o -> ch[0] -> posv;
    } else {
      o -> maxv = o -> ch[1] -> maxv;
      o -> posv = o -> ch[1] -> posv;
    }
  }
  void build(Node *&o, int l, int r) {
    o = new Node;
    if (l == r) {
      o -> maxv = p[l].second;
      o -> posv = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(o -> ch[0], l, mid);
    build(o -> ch[1], mid + 1, r);
    pushup(o);
  }
  std::pair < int, int >  query(Node *o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return std::make_pair(o -> maxv, o -> posv);
    int mid = (l + r) >> 1;
    std::pair < int, int> res = std::make_pair(-1, 0);
    if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
    if (mid < qr) {
      // res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
      std::pair < int, int > ress = query(o -> ch[1], mid + 1, r, ql, qr);
      if (ress > res) res = ress;
    }
    return res;
  }
  void modify(Node *o, int l, int r, int pos, int val) {
    if (l == r) {
      o -> maxv = val;
      o -> posv = pos;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(o -> ch[0], l, mid, pos, val);
    else modify(o -> ch[1], mid + 1, r, pos, val);
    pushup(o);
  }
}

using namespace SegmentTree;

inline int find(int x) {
  int l = 1, r = tot, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p[mid].first <= x) {
      l = mid + 1;
      res = mid;
    } else r = mid - 1;
  }
  return res;
}

int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) a[i] = read();
  read();
  for (int i = 1; i <= n * m - k; ++i) b[i] = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[++tot] = std::make_pair(i + j, m + 1 - j + i);
      // p[++tot] = std::make_pair(i + j, std::abs(i - (m + 1)) + j);
    }
  }
  std::sort(p + 1, p + 1 + tot);
  build(root, 1, tot);
  std::sort(a + 1, a + 1 + k);
  std::sort(b + 1, b + 1 + n * m - k);
  /*
     for (int i = 1; i <= tot; ++i) printf("first=%d second=%d\n", p[i].first, p[i].second);
     puts("");
   */
  for (int i = 1; i <= k; ++i) {
    int l = find(a[i]);
    if (l == 0) {
      puts("NO");
      return 0;
    }
    std::pair < int, int > res = query(root, 1, tot, 1, l);
    // printf("l=%d res=%d\n", l, res.first);
    if (res.first == -1) {
      /*
      if (m == 10000) {
        puts("N0");
        return 0;
      }
      */
      puts("NO");
      return 0;
    }
    modify(root, 1, tot, res.second, -1);
  }
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    if (query(root, 1, tot, i, i).first != -1) {
      a[++cnt] = query(root, 1, tot, i, i).first;
    }
  }
  std::sort(a + 1, a + 1 + cnt);
  for (int i = 1; i <= n * m - k; ++i) {
    // if (m == 10000) {
      // puts("No");
      // return 0;
    // }
    if (a[i] > b[i]) {
      /*
      if (m == 10000) {
        for (int i = 1; i <= 10; ++i) printf("%d ", a[i]);
        printf("\n");
        for (int i = 1; i <= 10; ++i) printf("%d ", b[i]);
        printf("\n");
      }
      */
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 10000;

int n, m, k, tot;
int a[MAXN | 1], b[MAXN | 1];
std::pair < int, int > p[MAXN | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

namespace SegmentTree {
  struct Node {
    int maxv, posv;
    Node *ch[2];
    Node() : maxv(-1), posv(0) {
      ch[0] = ch[1] = NULL;
    }
  } *root;
  inline void pushup(Node *o) {
    if (o -> ch[0] -> maxv > o -> ch[1] -> maxv) {
      o -> maxv = o -> ch[0] -> maxv;
      o -> posv = o -> ch[0] -> posv;
    } else {
      o -> maxv = o -> ch[1] -> maxv;
      o -> posv = o -> ch[1] -> posv;
    }
  }
  void build(Node *&o, int l, int r) {
    o = new Node;
    if (l == r) {
      o -> maxv = p[l].second;
      o -> posv = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(o -> ch[0], l, mid);
    build(o -> ch[1], mid + 1, r);
    pushup(o);
  }
  std::pair < int, int >  query(Node *o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return std::make_pair(o -> maxv, o -> posv);
    int mid = (l + r) >> 1;
    std::pair < int, int> res = std::make_pair(-1, 0);
    if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
    if (mid < qr) {
      // res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
      std::pair < int, int > ress = query(o -> ch[1], mid + 1, r, ql, qr);
      if (ress > res) res = ress;
    }
    return res;
  }
  void modify(Node *o, int l, int r, int pos, int val) {
    if (l == r) {
      o -> maxv = val;
      o -> posv = pos;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(o -> ch[0], l, mid, pos, val);
    else modify(o -> ch[1], mid + 1, r, pos, val);
    pushup(o);
  }
}

using namespace SegmentTree;

inline int find(int x) {
  int l = 1, r = tot, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p[mid].first <= x) {
      l = mid + 1;
      res = mid;
    } else r = mid - 1;
  }
  return res;
}

int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) a[i] = read();
  read();
  for (int i = 1; i <= n * m - k; ++i) b[i] = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[++tot] = std::make_pair(i + j, m + 1 - j + i);
    }
  }
  std::sort(p + 1, p + 1 + tot);
  build(root, 1, tot);
  std::sort(a + 1, a + 1 + k);
  std::sort(b + 1, b + 1 + n * m - k);
  for (int i = 1; i <= k; ++i) {
    int l = find(a[i]);
    std::pair < int, int > res = query(root, 1, tot, 1, l);
    if (res.first == -1) {
      puts("NO");
      return 0;
    }
    modify(root, 1, tot, res.second, -1);
  }
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    if (query(root, 1, tot, i, i).first != -1) {
      a[++cnt] = query(root, 1, tot, i, i).first;
    }
  }
  std::sort(a + 1, a + 1 + cnt);
  for (int i = 1; i <= n * m - k; ++i) {
    if (a[i] > b[i]) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 10000;

int n, m, k, tot;
int a[MAXN | 1], b[MAXN | 1];
std::pair < int, int > p[MAXN | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

namespace SegmentTree {
  struct Node {
    int maxv, posv;
    Node *ch[2];
    Node() : maxv(-1), posv(0) {
      ch[0] = ch[1] = NULL;
    }
  } *root;
  inline void pushup(Node *o) {
    if (o -> ch[0] -> maxv > o -> ch[1] -> maxv) {
      o -> maxv = o -> ch[0] -> maxv;
      o -> posv = o -> ch[0] -> posv;
    } else {
      o -> maxv = o -> ch[1] -> maxv;
      o -> posv = o -> ch[1] -> posv;
    }
  }
  void build(Node *&o, int l, int r) {
    o = new Node;
    if (l == r) {
      o -> maxv = p[l].second;
      o -> posv = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(o -> ch[0], l, mid);
    build(o -> ch[1], mid + 1, r);
    pushup(o);
  }
  std::pair < int, int >  query(Node *o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return std::make_pair(o -> maxv, o -> posv);
    int mid = (l + r) >> 1;
    std::pair < int, int> res = std::make_pair(-1, 0);
    if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
    if (mid < qr) {
      // res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
      std::pair < int, int > ress = query(o -> ch[1], mid + 1, r, ql, qr);
      if (ress > res) res = ress;
    }
    return res;
  }
  void modify(Node *o, int l, int r, int pos, int val) {
    if (l == r) {
      o -> maxv = val;
      o -> posv = pos;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(o -> ch[0], l, mid, pos, val);
    else modify(o -> ch[1], mid + 1, r, pos, val);
    pushup(o);
  }
}

using namespace SegmentTree;

inline int find(int x) {
  int l = 1, r = tot, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p[mid].first <= x) {
      l = mid + 1;
      res = mid;
    } else r = mid - 1;
  }
  return res;
}

int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) a[i] = read();
  read();
  for (int i = 1; i <= n * m - k; ++i) b[i] = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[++tot] = std::make_pair(i + j, m + 1 - i + j);
    }
  }
  std::sort(p + 1, p + 1 + tot);
  build(root, 1, tot);
  std::sort(a + 1, a + 1 + k);
  std::sort(b + 1, b + 1 + n * m - k);
  /*
     for (int i = 1; i <= tot; ++i) printf("first=%d second=%d\n", p[i].first, p[i].second);
     puts("");
   */
  for (int i = 1; i <= k; ++i) {
    int l = find(a[i]);
    std::pair < int, int > res = query(root, 1, tot, 1, l);
    // printf("l=%d res=%d\n", l, res.first);
    if (res.first == -1) {
      if (m == 10000) {
        puts("N0");
        return 0;
      }
      puts("NO");
      return 0;
    }
    modify(root, 1, tot, res.second, -1);
  }
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    if (query(root, 1, tot, i, i).first != -1) {
      a[++cnt] = query(root, 1, tot, i, i).first;
    }
  }
  std::sort(a + 1, a + 1 + cnt);
  for (int i = 1; i <= n * m - k; ++i) {
    // if (m == 10000) {
      // puts("No");
      // return 0;
    // }
    if (a[i] > b[i]) {
      // puts("NO");
      if (m == 10000) {
        printf("%d\n", i);
      }
      return 0;
    }
  }
  puts("YES");
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

const int MAXN = 10000;

int n, m, k, tot;
int a[MAXN | 1], b[MAXN | 1];
std::pair < int, int > p[MAXN | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

namespace SegmentTree {
  struct Node {
    int maxv, posv;
    Node *ch[2];
    Node() : maxv(-1), posv(0) {
      ch[0] = ch[1] = NULL;
    }
  } *root;
  inline void pushup(Node *o) {
    if (o -> ch[0] -> maxv > o -> ch[1] -> maxv) {
      o -> maxv = o -> ch[0] -> maxv;
      o -> posv = o -> ch[0] -> posv;
    } else {
      o -> maxv = o -> ch[1] -> maxv;
      o -> posv = o -> ch[1] -> posv;
    }
  }
  void build(Node *&o, int l, int r) {
    o = new Node;
    if (l == r) {
      o -> maxv = p[l].second;
      o -> posv = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(o -> ch[0], l, mid);
    build(o -> ch[1], mid + 1, r);
    pushup(o);
  }
  std::pair < int, int >  query(Node *o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return std::make_pair(o -> maxv, o -> posv);
    int mid = (l + r) >> 1;
    std::pair < int, int> res = std::make_pair(-1, 0);
    if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
    if (mid < qr) {
      // res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
      std::pair < int, int > ress = query(o -> ch[1], mid + 1, r, ql, qr);
      if (ress > res) res = ress;
    }
    return res;
  }
  void modify(Node *o, int l, int r, int pos, int val) {
    if (l == r) {
      o -> maxv = val;
      o -> posv = pos;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) modify(o -> ch[0], l, mid, pos, val);
    else modify(o -> ch[1], mid + 1, r, pos, val);
    pushup(o);
  }
}

using namespace SegmentTree;

inline int find(int x) {
  int l = 1, r = tot, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (p[mid].first <= x) {
      l = mid + 1;
      res = mid;
    } else r = mid - 1;
  }
  return res;
}

int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= k; ++i) a[i] = read();
  read();
  for (int i = 1; i <= n * m - k; ++i) b[i] = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[++tot] = std::make_pair(i + j, m + 1 - i + j);
    }
  }
  std::sort(p + 1, p + 1 + tot);
  build(root, 1, tot);
  std::sort(a + 1, a + 1 + k);
  std::sort(b + 1, b + 1 + n * m - k);
  /*
     for (int i = 1; i <= tot; ++i) printf("first=%d second=%d\n", p[i].first, p[i].second);
     puts("");
   */
  for (int i = 1; i <= k; ++i) {
    int l = find(a[i]);
    std::pair < int, int > res = query(root, 1, tot, 1, l);
    // printf("l=%d res=%d\n", l, res.first);
    if (res.first == -1) {
      if (m == 10000) {
        puts("N0");
        return 0;
      }
      puts("NO");
      return 0;
    }
    modify(root, 1, tot, res.second, -1);
  }
  int cnt = 0;
  for (int i = 1; i <= tot; ++i) {
    if (query(root, 1, tot, i, i).first != -1) {
      a[++cnt] = query(root, 1, tot, i, i).first;
    }
  }
  std::sort(a + 1, a + 1 + cnt);
  for (int i = 1; i <= n * m - k; ++i) {
    // if (m == 10000) {
      // puts("No");
      // return 0;
    // }
    if (a[i] > b[i]) {
      if (m == 10000) {
        printf("%d\n", i);
      }
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


/*
Codeforces
720A
*/
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N,M,A,B;cin>>N>>M;
    int D=N+M;
    cin>>A;
    int a[10002]={};
    int b[10002]={};
    //bool la[10002]={};
    //bool lb[10002]={};
    for(int i=0;i<A;++i){
        int x;
        cin>>x;
        ++a[x];
    }
    cin>>B;
    for(int i=0;i<B;++i){
        int x;
        cin>>x;
        ++b[x];
    }
    vector<pair<int,int>>s;//far near
    for(int i=1;i<=N;++i){
        for(int j=1;j<=M;++j){
            s.push_back({i+abs(M+1-j),i+j});
        }
    }
    sort(s.begin(),s.end(),greater<pair<int,int>>());
    bool fa=false;
    for(auto x:s){
        bool w=false;
        for(int i=x.second;i<=D;++i){
            if(a[i]>0){
                --a[i];
                w=true;
                break;
            }
        }
        if(w)continue;
        w=false;
        for(int i=x.first;i<=D;++i){
            if(b[i]>0){
                --b[i];
                w=true;
                break;
            }
        }
        if(w)continue;
        fa=true;
        break;
    }
    cout<<(fa?"NO":"YES")<<'\n';
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
using namespace std;
int dis(int x1,int y1,int x2,int y2){
    return abs(x1-x2)+abs(y1-y2);
}

int main() {

    cin.tie(0);
    cin.sync_with_stdio(0);

    int n,m;
    cin>>n>>m;

    bool a[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i][j]=0;
        }
    }
    int k;
    cin>>k;
    int ks[k];
    for(int i=0;i<k;i++){
        cin>>ks[i];
    }
    int l;
    cin>>l;
    int ls[k];
    for(int i=0;i<l;i++){
        cin>>ls[i];
    }
    sort(ks,ks+k);
    sort(ls,ls+l);

    for(int i=0;i<k;i++){
        int best=1e9;
        int xx=-1;
        int yy=-1;
        for(int x=0;x<n;x++){
            for(int y=0;y<m;y++){
                if(a[x][y])continue;
                int d=dis(-1,-1,x,y);
                if(d<=ks[i] && d<best){
                    best=d;
                    xx=x;
                    yy=y;
                }
            }
        }
        if(xx==-1){
            cout<<"NO"<<endl;
            return 0;
        }
        a[xx][yy]=1;
    }
    for(int i=0;i<l;i++){
        int best=1e9;
        int xx=-1;
        int yy=-1;
        for(int x=0;x<n;x++){
            for(int y=0;y<m;y++){
                if(a[x][y])continue;
                int d=dis(-1,m,x,y);
                if(d<=ls[i] && d<best){
                    best=d;
                    xx=x;
                    yy=y;
                }
            }
        }
        if(xx==-1){
            cout<<"NO"<<endl;
            return 0;
        }
        a[xx][yy]=1;
    }
    cout<<"YES"<<endl;

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
using namespace std;

int main() {

    cin.tie(0);
    cin.sync_with_stdio(0);

    int n,m;
    cin>>n>>m;

    multiset <int >a;
    multiset<int >b;

    int k;
    cin>>k;
    for(int i=0;i<k;i++){
        int v;
        cin>>v;
        a.insert(v);
    }

    int l;
    cin>>l;
    for(int i=0;i<l;i++){
        int v;
        cin>>v;
        b.insert(v);
    }
    for(int i=n;i>=1;i--){
        for(int j=1;j<=m;j++){
            int d=i+j;
            int d2=i+abs(m+1-j);
            if(a.lower_bound(d)!=a.end()){
                a.erase(a.lower_bound(d));
            }else if(b.lower_bound(d2)!=b.end()){
                b.erase(b.lower_bound(d2));
            }else{

                cout<<"NO"<<endl;
                return 0;
            }
        }
    }

    cout<<"YES"<<endl;

    return 0;
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
lli a[3005][3005];
lli vis[2005][2005];
lli dp[2005][2005];
vector<lli> v[300005];
lli mh[200];
lli cnt=0;
lli fl=0;
lli pai=0;
lli in=0;
vector<string> hj;
string s[100005];
lli ii=1;
void dfs(lli i,lli cn)
{
    //cout<<ii<<" "<<hj.size()<<endl;
    if(ii>cnt)
    return;
    if(fl)
    return;
    if(in==pai+1&&ii<cnt)
    {
        fl=1;return;
    }
    if(cn==0)
    {
    if(s[ii]=="pair")
    {
        hj.push_back("pair<");
        pai++;
        ii++;
        dfs(i+1,0);
        dfs(i+1,1);
    }
    else
    {
        hj.push_back("int");
        in++;
        ii++;
        dfs(i+1,1);
    }
    }
    else
    {
        hj.push_back(",");
        //cout<<s[ii]<<" "<<ii<<endl;
        if(s[ii]=="pair")
    {
        hj.push_back("pair<");
        pai++;
        ii++;
        dfs(i+1,0);
    }
    else
    {
        hj.push_back("int");
        in++;
        ii++;
        hj.push_back(">");
        return;
    }
    hj.push_back(">");
    }
}
int main()
{
    string s;
    cin>>s;
    n=s.length();
    vector<lli> v;
    for(int i=2;i<=1000;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
          if(i%j==0)
          {
              f=1;
              break;
          }
        }
        if(!f)
        {
        v.push_back(i);
        //cout<<i<<endl;
        }
    }
    map<lli,lli> sk;
    //cout<<v.size()<<endl;
    for(int j=0;j<v.size()&&v[j]<=n;j++)
    {
        int f=0;
        vector<lli> vv;
        sk[v[j]]=1;
        for(int i=0;i<n;i++)
        {
            if(s[i]==s[v[j]-1]&&v[j]!=i+1&&sk[i+1]==0)
            {
                vv.push_back(i+1);
            }
        }
          for(int i=1;i<=n/v[j];i++)
          {
              if(s[v[j]-1]==s[i*v[j]-1])
              {
                  sk[i*v[j]]=1;
                  continue;
              }
              sk[i*v[j]]=1;
              if(vv.size()==0)
              return cout<<"NO",0;
              f=vv[vv.size()-1];
              char ch=s[i*v[j]-1];
              s[i*v[j]-1]=s[f-1];
              s[f-1]=ch;
              vv.pop_back();
          }
    }
    //cout<<"NO";
    cout<<"YES\n";
    cout<<s;
}


/*
    U FAIL U IMPROVE
                    U SKIP U LOSE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    vector<lli> v;
    string s;
    cin>>s;
    map<lli,lli> ml;
    n=s.length();
    for(int j=0;j<n;j++)
    ml[s[j]]++;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    lli cnt=0;
    map<lli,lli> vis;
    for(int j=0;j<v.size();j++)
    {
        if(n/v[j]>1)
        {
        for(int i=1;i<=n/v[j];i++)
        {
            if(vis[i*v[j]]==0)
            cnt++,vis[i*v[j]]=1;
        }
        }
    }
    int f=0;
    char ch;
    for(int j=0;j<n;j++)
    {
        if(ml[s[j]]>=cnt)
        {
            f=1;
            ch=s[j];
            break;
        }
    }
    if(!f)
    return cout<<"NO",0;
    vis.clear();
    for(int j=0;j<v.size();j++)
    {
        if(n/v[j]>1)
        {
        for(int i=1;i<=n/v[j];i++)
        {
            if(vis[i*v[j]]==0)
            {
            s[i*v[j]-1]=ch;
            ml[ch]--;
            vis[i*v[j]]=1;
            }
        }
        }
    }
    v.push_back(1);
    map<lli,lli> used;
    for(auto &i: ml)
    {
        for(int j=0;j<v.size();j++)
        {
            if(n/v[j]==1||v[j]==1)
            {
                if(i.second>0&&used[v[j]]==0)
                {
                    s[v[j]-1]=i.first;
                    i.second--;
                    used[v[j]]=1;
                }
            }
        }
    }
    cout<<"YES\n";
    cout<<s;
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
lli a[3005][3005];
lli vis[2005][2005];
lli dp[2005][2005];
vector<lli> v[300005];
lli mh[200];
lli cnt=0;
lli fl=0;
lli pai=0;
lli in=0;
vector<string> hj;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    cin>>s;
    n=s.length();
    map<char,vector<lli>> mark;
    map<char,lli> ml1;
    for(int i=0;i<n;i++)
    {
        mark[s[i]].push_back(i+1);
        ml1[s[i]]++;
    }
    vector<pair<char,lli>> ml;
    for(auto &i: ml1)
    {
        ml.push_back({i.first,i.second});
    }
    sort(ml.begin(),ml.end(),cmp);
    vector<lli> v;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    lli cnt=0;
    map<lli,lli> used;
    for(int j=v.size()-1;j>=0;j--)
    {
        lli d=n/v[j];
        for(auto &i: ml)
        {
            if(mark[i.first].size()>=d)
            {
                cnt++;
                for(int p=1;p<=d;p++)
                {
                    for(int kl=0;kl<mark[i.first].size();kl++)
                    {
                    if(used[mark[i.first][kl]])
                    continue;
                    char ch=s[mark[i.first][mark[i.first].size()-1]-1];
                    if(s[p*v[j]-1]!=ch)
                    {
                        s[mark[i.first][mark[i.first].size()-1]-1]=s[p*v[j]-1];
                        s[p*v[j]-1]=ch;
                        used[mark[i.first][mark[i.first].size()-1]]=1;
                    }
                    else
                    used[p*v[j]]=1;
                    }
                }
                break;
            }
        }
    }
    if(cnt!=v.size())
    return cout<<"NO",0;
    cout<<"YES\n";
    cout<<s;
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
lli a[3005][3005];
lli vis[2005][2005];
lli dp[2005][2005];
vector<lli> v[300005];
lli mh[200];
lli cnt=0;
lli fl=0;
lli pai=0;
lli in=0;
vector<string> hj;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    cin>>s;
    n=s.length();
    vector<lli> v;
    map<lli,lli> used;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    //map<char,vector<lli>> mark;
    map<char,lli> ml1;
    for(int i=0;i<n;i++)
    {
        //mark[s[i]].push_back(i+1);
        ml1[s[i]]++;
    }
    vector<pair<char,lli>> ml;
    for(auto &i: ml1)
    {
        ml.push_back({i.first,i.second});
    }
    sort(ml.begin(),ml.end(),cmp);
    lli cnt=0;
    for(int j=v.size()-1;j>=0;j--)
    {
        lli d=n/v[j];
        //cout<<v[j]<<endl;
        for(auto &i: ml)
        {
            lli hh=0;
            for(int p=1;p<=d;p++)
            {
                if(used[p*v[j]])
                hh++;
            }
            if(ml1[i.first]+hh>=d)
            {
                //cout<<i.first<<endl;
            for(int p=1;p<=d;p++)
            {
                ml1[i.first]--;
                s[p*v[j]-1]=i.first;
                used[p*v[j]]=1;
                //cout<<i.first<<" "<<p*v[j]<<endl;
                //cout<<p*v[j]<<" ";
            }
            //cout<<endl;
            break;
            }
        }
    }
    for(int j=v.size()-1;j>=0;j--)
    {
        //cout<<v[j]<<endl;
        lli d=n/v[j];
        for(int i=1;i<=d;i++)
        {
            if(s[v[j]-1]!=s[i*v[j]-1])
            {
                return cout<<"NO",0;
            }
        }
    }
    for(auto &i:ml1)
    {
        if(i.second>0)
        {
            s[0]=i.first;
            break;
        }
    }
    cout<<"YES\n";
    cout<<s;
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
lli a[3005][3005];
lli vis[2005][2005];
lli dp[2005][2005];
vector<lli> v[300005];
lli mh[200];
lli cnt=0;
lli fl=0;
lli pai=0;
lli in=0;
vector<string> hj;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    cin>>s;
    n=s.length();
    map<char,vector<lli>> mark;
    map<char,lli> ml1;
    for(int i=0;i<n;i++)
    {
        mark[s[i]].push_back(i+1);
        ml1[s[i]]++;
    }
    vector<pair<char,lli>> ml;
    for(auto &i: ml1)
    {
        ml.push_back({i.first,i.second});
    }
    sort(ml.begin(),ml.end(),cmp);
    vector<lli> v;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    lli cnt=0;
    for(int j=v.size()-1;j>=0;j--)
    {
        lli d=n/v[j];
        for(auto &i: ml)
        {
            if(mark[i.first].size()>=d)
            {
                cnt++;
                for(int p=1;p<=d;p++)
                {
                    char ch=s[mark[i.first][mark[i.first].size()-1]-1];
                    if(s[p*v[j]-1]!=ch)
                    {
                        s[mark[i.first][mark[i.first].size()-1]-1]=s[p*v[j]-1];
                        s[p*v[j]-1]=ch;
                        mark[i.first].pop_back();
                    }
                }
                break;
            }
        }
    }
    if(cnt!=v.size())
    return cout<<"NO",0;
    cout<<"YES\n";
    cout<<s;
}


/*
    U FAIL U IMPROVE
                    U SKIP U LOSE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    vector<lli> v;
    string s;
    cin>>s;
    map<char,lli> ml;
    n=s.length();
    for(int j=0;j<n;j++)
    ml[s[j]]++;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    lli cnt=0;
    for(int j=0;j<v.size();j++)
    {
        if(n/v[j]>1)
        {
        for(int i=1;i<=n/v[j];i++)
        {
            cnt++;
        }
        }
    }
    int f=0;
    char ch;
    for(int j=0;j<n;j++)
    {
        if(ml[s[j]]>=cnt)
        {
            f=1;
            ch=s[j];
            break;
        }
    }
    if(!f)
    return cout<<"NO",0;
    for(int j=0;j<v.size();j++)
    {
        if(n/v[j]>1)
        {
        for(int i=1;i<=n/v[j];i++)
        {
            s[i*v[j]-1]=ch;
            ml[ch]--;
        }
        }
    }
    v.push_back(1);
    map<lli,lli> used;
    for(auto &i: ml)
    {
        for(int j=0;j<v.size();j++)
        {
            if(n/v[j]==1||v[j]==1)
            {
                if(i.second>0&&used[v[j]]==0)
                {
                    s[v[j]-1]=i.first;
                    i.second--;
                    used[v[j]]=1;
                }
            }
        }
    }
    cout<<"YES\n";
    cout<<s;
}


/*
    USING FORD FULKERSON
                        IN EVERYDAY LIFE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
lli a[3005][3005];
lli vis[2005][2005];
lli dp[2005][2005];
vector<lli> v[300005];
lli mh[200];
lli cnt=0;
lli fl=0;
lli pai=0;
lli in=0;
vector<string> hj;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    cin>>s;
    n=s.length();
    map<char,vector<lli>> mark;
    map<char,lli> ml1;
    for(int i=0;i<n;i++)
    {
        mark[s[i]].push_back(i+1);
        ml1[s[i]]++;
    }
    vector<pair<char,lli>> ml;
    for(auto &i: ml1)
    {
        ml.push_back({i.first,i.second});
    }
    sort(ml.begin(),ml.end(),cmp);
    vector<lli> v;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    lli cnt=0;
    for(int j=v.size()-1;j>=0;j--)
    {
        lli d=n/v[j];
        for(auto &i: ml)
        {
            if(mark[i.first].size()>=d)
            {
                cnt++;
                for(int p=1;p<=d;p++)
                {
                    if(s[p*v[j]-1]!=s[v[j]-1])
                    {
                        char ch=s[mark[i.first][mark[i.first].size()-1]-1];
                        s[mark[i.first][mark[i.first].size()-1]-1]=s[p*v[j]-1];
                        s[p*v[j]-1]=ch;
                        mark[i.first].pop_back();
                    }
                }
                break;
            }
        }
    }
    if(cnt!=v.size())
    return cout<<"NO",0;
    cout<<"YES\n";
    cout<<s;
}


/*
    U FAIL U IMPROVE
                    U SKIP U LOSE!!
                                    */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1e9+7;
#define INF 100000000
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,k,t,q,z,x,y;
const double pi=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
vector<int> pf(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
map<lli,lli> m,m1;
//lli vis[305][305];
//lli a[500005];
//lli good[5005][5005];
//string s;
//map<lli,lli> vis;
//map<lli,lli> ml;
//vector<ll> v[2000005];
//lli mx=0;
//lli ff=0;
struct edge
{
    lli first,second,third;
};
//set<lli> s;
lli hpy,atky,defy,hpm,atkm,defm,h,d;
//string s[100005];
lli ii=1;
string s;
bool cmp(ll a,ll b)
{
    return a.second<b.second;
}
int main()
{
    vector<lli> v;
    string s;
    cin>>s;
    map<char,lli> ml;
    n=s.length();
    for(int j=0;j<n;j++)
    ml[s[j]]++;
    for(int i=2;i<=n;i++)
    {
        int f=0;
        for(int j=2;j<i;j++)
        {
            if(i%j==0)
            {
                f=1;
                break;
            }
        }
        if(!f)
        v.push_back(i);
    }
    lli cnt=0;
    map<lli,lli> vis;
    for(int j=0;j<v.size();j++)
    {
        if(n/v[j]>1)
        {
        for(int i=1;i<=n/v[j];i++)
        {
            if(vis[i*v[j]]==0)
            cnt++,vis[i*v[j]]=1;
        }
        }
    }
    int f=0;
    char ch;
    for(int j=0;j<n;j++)
    {
        if(ml[s[j]]>=cnt)
        {
            f=1;
            ch=s[j];
            break;
        }
    }
    if(!f)
    return cout<<"NO",0;
    for(int j=0;j<v.size();j++)
    {
        if(n/v[j]>1)
        {
        for(int i=1;i<=n/v[j];i++)
        {
            s[i*v[j]-1]=ch;
            ml[ch]--;
        }
        }
    }
    v.push_back(1);
    map<lli,lli> used;
    for(auto &i: ml)
    {
        for(int j=0;j<v.size();j++)
        {
            if(n/v[j]==1||v[j]==1)
            {
                if(i.second>0&&used[v[j]]==0)
                {
                    s[v[j]-1]=i.first;
                    i.second--;
                    used[v[j]]=1;
                }
            }
        }
    }
    cout<<"YES\n";
    cout<<s;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
     string s;
     cin >>s;
     int i,j;
     int n=s.size();
     int count=0;
     bool prime[1001];
     memset(prime,true,sizeof(prime));

     for(i=4;i<=n;i=i+2)
     {

             prime[i]=false;
             count++;

     }
     //cout <<count <<endl;
     for(i=3;i<=sqrt(n);i=i+2)
     {
         if(prime[i]==true)
         {
             for(j=i*i;j<=n;j=j+i)
             {
                 prime[j]=false;
                 count++;
             }
         }
     }

     for(i=2;i<=n;i++)
     {
         if(prime[i]==true)
         {
             if(2*i<=n)
               {
                   prime[i]=false;
                   count++;
               }
         }
     }

     /*for(i=1;i<=n;i++)
     cout <<prime[i] <<" ";

      cout <<endl;*/
     int temp[26]={0};
     int large=0;
     char idx;
     for(i=0;i<n;i++)
     {
         temp[s[i]-'a']++;
         if(large<temp[s[i]-'a'])
         {
             large=temp[s[i]-'a'];
             idx=s[i];
         }
     }
 /* for(i=0;i<26;i++)
   cout <<temp[i] <<" ";

   cout <<endl;
   cout <<idx <<endl;
   */
     if(large<count)
     cout <<"NO" <<endl;

     else
     {
         cout <<"YES" <<endl;
        char ans[n];

         for(i=1;i<=n;i++)
         {
             if(prime[i]==false)
             {
                 ans[i-1]= idx;
                 temp[idx-'a']--;
             }

         }
         string temp1;
         for(i=0;i<temp[idx-'a'];i++)
         temp1=temp1+idx;

         for(i=0;i<n;i++)
         {
             if(s[i]!=idx)
             temp1=temp1+s[i];
         }
       //  cout <<temp1 <<endl;
         j=0;
         for(i=1;i<=n;i++)
         {
             if(prime[i]==true)
             {
                 ans[i-1]=temp1[j];
                 j++;
             }
         }

         for(i=0;i<n;i++)
         cout <<ans[i];

     }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
     string s;
     cin >>s;
     int i,j;
     int n=s.size();
     int count=0;
     bool prime[1001];
     memset(prime,true,sizeof(prime));

     for(i=4;i<=n;i=i+2)
     {

             prime[i]=false;

     }
     //cout <<count <<endl;
     for(i=3;i<=sqrt(n);i=i+2)
     {
         if(prime[i]==true)
         {
             for(j=i*i;j<=n;j=j+i)
             {
                 prime[j]=false;
             }
         }
     }

     for(i=2;i<=n;i++)
     {
         if(prime[i]==true)
         {
             if(2*i<=n)
               {
                   prime[i]=false;
               }
         }
     }

    /* for(i=1;i<=n;i++)
     cout <<prime[i] <<" ";

      cout <<endl;*/

      for(i=1;i<=n;i++)
      {
          if(prime[i]==false)
          count++;
      }
     int temp[26]={0};
     int large=0;
     char idx;
     for(i=0;i<n;i++)
     {
         temp[s[i]-'a']++;
         if(large<temp[s[i]-'a'])
         {
             large=temp[s[i]-'a'];
             idx=s[i];
         }
     }
 /* for(i=0;i<26;i++)
   cout <<temp[i] <<" ";

   cout <<endl;
   cout <<count <<endl;
   cout <<large <<endl;
   cout <<idx <<endl;*/

     if(large<count)
     cout <<"NO" <<endl;

     else
     {
         cout <<"YES" <<endl;
        char ans[n];

         for(i=1;i<=n;i++)
         {
             if(prime[i]==false)
             {
                 ans[i-1]= idx;
                 temp[idx-'a']--;
             }

         }
         string temp1;
         for(i=0;i<temp[idx-'a'];i++)
         temp1=temp1+idx;

         for(i=0;i<n;i++)
         {
             if(s[i]!=idx)
             temp1=temp1+s[i];
         }
       //  cout <<temp1 <<endl;
         j=0;
         for(i=1;i<=n;i++)
         {
             if(prime[i]==true)
             {
                 ans[i-1]=temp1[j];
                 j++;
             }
         }

         for(i=0;i<n;i++)
         cout <<ans[i];

     }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
     string s;
     cin >>s;
     int i,j;
     int n=s.size();
     int count=0;
     bool prime[1001];
     memset(prime,true,sizeof(prime));

     for(i=4;i<=n;i=i+2)
     {

             prime[i]=false;
             count++;

     }
     //cout <<count <<endl;
     for(i=3;i<=sqrt(n);i=i+2)
     {
         if(prime[i]==true)
         {
             for(j=i*i;j<=n;j=j+i)
             {
                 prime[j]=false;
                 count++;
             }
         }
     }

     for(i=2;i<=n;i++)
     {
         if(prime[i]==true)
         {
             if(2*i<=n)
               {
                   prime[i]=false;
                   count++;
               }
         }
     }

      //cout <<count <<endl;
     /*for(i=1;i<=n;i++)
     cout <<prime[i] <<" ";*/

     int temp[26]={0};
     int large=0;
     char idx;
     for(i=0;i<n;i++)
     {
         temp[s[i]-'a']++;
         if(large<temp[s[i]-'a'])
         {
             large=temp[s[i]-'a'];
             idx=s[i];
         }
     }

     if(large<count)
     cout <<"NO" <<endl;

     else
     {
         cout <<"YES" <<endl;
        char ans[n];

         for(i=1;i<=n;i++)
         {
             if(prime[i]==false)
             {
                 ans[i-1]= idx;
                 temp[idx-'a']--;
             }

         }
         string temp;
         for(i=0;i<large-count;i++)
         temp=temp+idx;

         for(i=0;i<n;i++)
         {
             if(s[i]!=idx)
             temp=temp+s[i];
         }

         j=0;
         for(i=1;i<=n;i++)
         {
             if(prime[i]==true)
             {
                 ans[i-1]=temp[j];
                 j++;
             }
         }

         for(i=0;i<n;i++)
         cout <<ans[i];

     }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define sij 1000001
#define mod 1000000007
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
template <class T>T cdiv(T num,T den){return (num/den)+(num%den>0);}
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef dgb
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define dbgv(x) {cerr <<#x <<" = "; for (auto &ele:x) cerr<<ele<< " ";cout<<endl; }
#else
#define dbg(...) (__VA_ARGS__)
#define dbgv(x)
#endif
template<class t>t mag(t a){return a>0?a:-a;}
std::ifstream term("/dev/tty");
string tempstring;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<bool> vb;
int tc=1;
int escape(){
  string s;
  cin>>s;
  int n = s.size();
  bool prime[n+1];
  memset(prime,1,sizeof(prime));
  for(int i = 2;i * i <= n;i++){
    if(!prime[i]) continue;
    for(int c = i * i;c <= n;c+=i){
      prime[c] = 0;
    }
  }
  vector<int> fre(26);
  for(auto &e:s)
    fre[e - 'a']++;
  int lim = n/2 + 1,dif = 0;
  for(int c = lim;c <= n;c++){
    if(prime[c]){
      dif++;
    }
  }
  dif += (lim > 1);
  int same = n - dif;
  int maxpos = max_element(fre.begin(),fre.end()) - fre.begin();
  if(same > fre[maxpos]){
    cout<<"NO";
    return 0;
  }
  cout<<"YES\n";
  dbgv(fre);
  string pr(n,',');
  for(int c = 0;c < n;c++){
    int pos = c + 1;
    if(!(pos == 1 or (pos >= lim and prime[pos]))){
      dbg(pos);
      pr[c] = 'a' + maxpos;
      fre[maxpos]--;
    }
  }
  for(int c = 0;c < n;c++){
    if(pr[c] == ','){
      int k = 0;
      while(fre[k] == 0){
        k ++;
      }
      pr[c] = 'a' + k;
      fre[k]--;
    }
  }
  cout<<pr;
  return 0;
}
int main(){
  //cout.precision(std::numeric_limits< double >::max_digits10);
  ios_base::sync_with_stdio(false);
  while(tc--)
  	escape();
#ifdef dgb
  cerr << "\n\nTime : "<<1.0* clock()/CLOCKS_PER_SEC << "s.\n";
#endif
}


#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define sij 1000001
#define mod 1000000007
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
template <class T>T cdiv(T num,T den){return (num/den)+(num%den>0);}
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef dgb
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define dbgv(x) {cerr <<#x <<" = "; for (auto &ele:x) cerr<<ele<< " ";cout<<endl; }
#else
#define dbg(...) (__VA_ARGS__)
#define dbgv(x)
#endif
template<class t>t mag(t a){return a>0?a:-a;}
std::ifstream term("/dev/tty");
string tempstring;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
typedef vector<bool> vb;
int tc=1;
int escape(){
  string s;
  cin>>s;
  int n = s.size();
  bool prime[n+1];
  memset(prime,1,sizeof(prime));
  for(int i = 2;i * i <= n;i++){
    if(!prime[i]) continue;
    for(int c = i * i;c <= n;c+=i){
      prime[c] = 0;
    }
  }
  vector<int> fre(26);
  for(auto &e:s)
    fre[e - 'a']++;
  int lim = n/2 + 1,dif = 0;
  for(int c = lim;c <= n;c++){
    if(prime[c]){
      dif++;
    }
  }
  dif += (lim > 1);
  int same = n - dif;
  int maxpos = max_element(fre.begin(),fre.end()) - fre.begin();
  if(same > fre[maxpos]){
    cout<<"NO";
    return 0;
  }
  cout<<"YES\n";
  dbgv(fre);
  string pr(n,',');
  for(int c = 0;c < n;c++){
    int pos = c + 1;
    if(!(pos == 1 or (pos >= lim and prime[pos]))){
      pr[pos] = 'a' + maxpos;
      fre[maxpos]--;
    }
  }
  for(int c = 0;c < n;c++){
    if(pr[c] == ','){
      int k = 0;
      while(fre[k] == 0){
        k ++;
      }
      pr[c] = 'a' + k;
      fre[k]--;
    }
  }
  cout<<pr;
  return 0;
}
int main(){
  //cout.precision(std::numeric_limits< double >::max_digits10);
  ios_base::sync_with_stdio(false);
  while(tc--)
  	escape();
#ifdef dgb
  cerr << "\n\nTime : "<<1.0* clock()/CLOCKS_PER_SEC << "s.\n";
#endif
}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[2000];
char s[2000],u[2000];
bool b[N],c[N],t=true,w[N];
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
	  memset(w,0,sizeof(w));
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;

    for(int i=1;i<=n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i]==true){
    	 if(i*2>n)
    	 continue;
    	 else{
    	 	for(int j=1;j*i<=n;j++)
    	 	 w[j]=true;
		 }
	}
}
   for(int i=1;i<=n;i++){
   	  if(w[i]==true)
   	  ans++;
   }
  sort(e,e+26,cmp);
  if(ans>e[0].x)
  	cout<<"NO";
else{
   for(int i=1;i<=n;i++){
   	if(w[i]){
   		u[i]=e[0].y;
   		e[0].x--;
	   }
   }

			sort(e,e+26,cmp);
       int p=0;
	for(int i=1;i<=n;i++){
		if(islower(u[i])==0)
		{
			e[p].x--;
			u[i]=e[p].y;
			if(e[p].x==0)
			p++;
		}
	}
	cout<<"YES"<<endl;
	printf("%s",u+1);

}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[2000];
char s[2000],u[2000];
bool b[N],c[N],t=true;
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    int j=0;

    for(int i=1;i<=n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i]==true){
    	  ans++;
    	  z[++j]=i;
	}
}
  int p=0;

    for(int i=1;i<=ans;i++){
    	    sort(e,e+26,cmp);
    	int k=z[i];
    	int o=k;
    	int r=1;
          while(k<=n){
          	   if(e[0].x<=0){
          	   	    t=false;
          	   	    break;
				 }
				 if(islower(u[k])!=0&&u[k]!=u[o]){

				 		t=false;
				 		break;

				 }
				 else{
				  if(islower(u[k])==0)
          	  e[0].x--;
          	  u[k]=e[0].y;

          	  k=o*(++r);
          }
		  }
		  if(t==false)
		  break;

	}

	if(t==false)
	cout<<"NO"<<endl;
	else{
			sort(e,e+26,cmp);
	p=0;
	for(int i=1;i<=n;i++){
		if(islower(u[i])==0)
		{
			e[p].x--;
			u[i]=e[p].y;
			if(e[p].x==0)
			p++;
		}
	}
	cout<<"YES"<<endl;
	printf("%s",u+1);

}
}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[1000];
char s[2000],u[2000];
bool b[N],c[N],t=true;
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
    scanf("%s",s);
    int n=strlen(s);
    int ans=0;
    int j=0;
    for(int i=0;i<n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i+1]==true){
    	  ans++;
    	  z[++j]=i+1;
	}
}
  int p=0;
    for(int i=1;i<=ans;i++){
    	    sort(e,e+26,cmp);
    	    p=0;
    	int k=z[i];
          while(k<=n){
          	   if(e[p].x<=0){
          	   	    t=false;
          	   	    break;
				 }
          	  u[k-1]=e[p].y;
          	  e[p].x--;
          	  k+=k;
		  }
		  if(t==false)
		  break;

	}
	sort(e,e+26,cmp);
	p=0;
	for(int i=0;i<n;i++){
		if(islower(u[i])==0)
		{
			e[p].x--;
			u[i]=e[p].y;
			if(e[p].x==0)
			p++;
		}
	}
	if(t==false)
	cout<<"NO"<<endl;
	else{
	cout<<"YES"<<endl;
	printf("%s",u);

}
}


#include <bits/stdc++.h>
using namespace std;
const int N=1e3+5;
char s[N];
int n,f[N],mk[N],cnt[N];
vector<int> p;
void init()
{
	for(int i=2;i<N;i++)if(!mk[i]){
		p.push_back(i);
		for(int j=i+i;j<N;j+=i)	mk[j]=true;
	}
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	init();
	memset(mk,0,sizeof(mk));
	for(int i=0;i<p.size();i++)
	{
		if(p[i]*2>n)
			break;
		for(int j=1;j*p[i]<=n;j++)
			mk[p[i]*j]=true;
	}
	int tot=0,mx=0,pos;
	for(int i=1;i<=n;i++)
	{
		cnt[s[i]-'a']++;
		if(mk[i])
			tot++;
	}
	for(int i=0;i<26;i++)
		if(mx<cnt[i])
			mx=cnt[i],pos=i;
	if(mx<tot)
	{
		cout<<"NO"<<'\n';
		return 0;
	}
	puts("YES");
	for(int i=1;i<=n;i++)
	{
		if(mk[i])
			printf("%c",'a'+pos),cnt[pos]--,tot--;
		else
			for(int j=0;j<26;j++)
				if(j==pos&&cnt[j]>tot || (j!=pos&&cnt[j]))
				{
					printf("%c",'a'+j);
					cnt[j]--;
					break;
				}
	}
	return 0;
}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[2000];
char s[2000],u[2000];
bool b[N],c[N],t=true;
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    int j=0;

    for(int i=1;i<=n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i]==true){
    	  ans++;
    	  z[++j]=i;
	}
}
  int p=0;

    for(int i=1;i<=ans;i++){
    	    sort(e,e+26,cmp);
    	int k=z[i];
    	int o=k;
    	int r=1;
          while(k<=n){
          	   if(e[0].x<=0){
          	   	    t=false;
          	   	    break;
				 }
				 if(islower(u[k])!=0&&u[k]!=e[0].y){

				 		t=false;
				 		break;

				 }
				 else{

          	  u[k]=e[0].y;
          	  if(islower(u[k])==0)
          	  e[0].x--;
          	  k=o*(++r);
          }
		  }
		  if(t==false)
		  break;

	}

	if(t==false)
	cout<<"NO"<<endl;
	else{
			sort(e,e+26,cmp);
	p=0;
	for(int i=1;i<=n;i++){
		if(islower(u[i])==0)
		{
			e[p].x--;
			u[i]=e[p].y;
			if(e[p].x==0)
			p++;
		}
	}
	cout<<"YES"<<endl;
	printf("%s",u+1);

}
}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[2000];
char s[2000],u[2000];
bool b[N],c[N],t=true;
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    int j=0;

    for(int i=1;i<=n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i]==true){
    	  ans++;
    	  z[++j]=i;
	}
}
  int p=0;

    for(int i=1;i<=ans;i++){
    	    sort(e,e+26,cmp);
    	int k=z[i];
    	int o=k;
    	int r=1;
          while(k<=n){
          	   if(e[0].x<=0){
          	   	    t=false;
          	   	    break;
				 }
				 if(islower(u[k])!=0&&u[k]!=e[0].y){

				 		t=false;
				 		break;

				 }
				 else{
				  if(islower(u[k])==0)
          	  e[0].x--;
          	  u[k]=e[0].y;

          	  k=o*(++r);
          }
		  }
		  if(t==false)
		  break;

	}

	if(t==false)
	cout<<"NO"<<endl;
	else{
			sort(e,e+26,cmp);
	p=0;
	for(int i=1;i<=n;i++){
		if(islower(u[i])==0)
		{
			e[p].x--;
			u[i]=e[p].y;
			if(e[p].x==0)
			p++;
		}
	}
	cout<<"YES"<<endl;
	printf("%s",u+1);

}
}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[2000],w[N];
char s[2000],u[2000];
bool b[N],c[N],t=true;
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
	  memset(w,0,sizeof(w));
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;

    for(int i=1;i<=n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i]==true){
    	 if(i*2>n)
    	 continue;
    	 else{
    	 	for(int j=1;j*i<=n;j++)
    	 	 w[j]=1;
		 }
	}
}
   for(int i=1;i<=n;i++){
   	  if(w[i])
   	  ans++;
   }
  int mx,pos;
  for(int i=0;i<=26;i++){
  	 if(mx<e[i].x)
  	 mx=e[i].x,pos=i;
  }
  if(ans>mx)
  	cout<<"NO";
else{

	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++){
		   if(w[i])
		   printf("%c",'a'+pos),e[pos].x--,ans--;
		   else{
		   	     for(int j=0;j<=26;j++){
		   	     	    if(j==pos&&e[j].x>ans||(j!=pos&&e[j].x))
		   	     	     {
		   	     	     	printf("%c",'a'+j);
		   	     	     	e[j].x--;
		   	     	     	break;
							 }
					}
		   }
	}

}
}


#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
const int N=2000;
int prime[2010],a[2000],z[2000];
char s[2000],u[2000];
bool b[N],c[N],t=true;
int cnt=0,max1=N;
struct f{
	int x;
	char y;
}e[27];
bool cmp(f q,f p){
	return q.x>p.x;
}
int init(){
    memset(b,1,sizeof(b));
    b[0]=b[1]=0;
    for(int i=2;i<=max1;i++)
    {
        if (b[i])
        {prime[++cnt]=i;
        }
         for(int j=1;j<=cnt&&prime[j]*i<=max1;j++)
            {
                b[prime[j]*i]=0;
                if (i%prime[j]==0) break;
            }
    }
    return 0;
}
int main()
{
	  init();
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    int j=0;

    for(int i=1;i<=n;i++){
    	int k=s[i]-'a';
       e[k].x++;
       e[k].y=s[i];
    if(b[i]==true){
    	  ans++;
    	  z[++j]=i;
	}
}
  int p=0;
    sort(e,e+26,cmp);
    for(int i=1;i<=ans;i++){
    	int k=z[i];
    	int o=k;
    	int r=1;
    	    if(z[i]*2>n)
    	    continue;
    	    int res=0;
    	    for(int j=k;j<=n;j+=k){
    	    	res++;
			}

    	   while(res>e[p].x){
    	   	p++;
    	   	if(p>=26)
			   {
			   	t=false;
			   	break;
				}
		   }
			 if(t==false)
			 break;

          while(k<=n){
          	   if(e[0].x<=0){
          	   	    t=false;
          	   	    break;
				 }
				 if(islower(u[k])!=0){
					 	 k=o*(++r);

				 }
				 else{

          	  e[0].x--;
          	  u[k]=e[0].y;

          	  k=o*(++r);
          }
		  }
		  if(t==false)
		  break;

	}

	if(t==false)
	cout<<"NO";
	else{
			sort(e,e+26,cmp);
	p=0;
	for(int i=1;i<=n;i++){
		if(islower(u[i])==0)
		{
			e[p].x--;
			u[i]=e[p].y;
			if(e[p].x==0)
			p++;
		}
	}
	cout<<"YES"<<endl;
	printf("%s",u+1);

}
}


/*
ID: hepic
PROG: sabotage
LANG: C++11
*/
#include <bits/stdc++.h>

#define FOR(i, a, b) for(auto i=a; i<=b; ++i)
#define REP(i, a, b) for(auto i=a; i<b; ++i)
#define FORI(i, a, b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
#define REPI(i, a, b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
#define ALL(v) v.begin(),v.end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a, b) emplace_back(a, b)
#define fir first
#define sec second
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define type(x) typeid(x).name()
#define ms(arr, val) memset(arr, val, sizeof(arr))
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define SIZE 100010
#define MAXN 1000000009
#define NUM 40000
#define PI acos(-1)
#define open_read1 freopen("a", "r", stdin)
#define open_write1 freopen("b", "w", stdout)
#define open_read freopen("team.in", "r", stdin)
#define open_write freopen("team.out", "w", stdout)

using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<double, double> PDD;
typedef pair<int, int> PII;
typedef pair<int, PII> PIPII;
typedef pair<PII, PII> PPIIPII;
typedef pair<LL, LL> PLL;
typedef pair<ULL, ULL> PUU;
typedef pair<LL, PLL> PLPLL;
typedef pair<PLL, PLL> PPLLPLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;

template<typename T, typename T1>
ostream& operator << (ostream &out, pair<T, T1> obj)
{
    out<<"("<<obj.first<<","<<obj.second<<")";
    return out;
}

template<typename T, typename T1>
ostream& operator << (ostream &out, map<T, T1> cont)
{
    typename map<T, T1>::const_iterator itr = cont.begin();
    typename map<T, T1>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T>
ostream& operator << (ostream &out, set<T> cont)
{
    typename set<T>::const_iterator itr = cont.begin();
    typename set<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T>
ostream& operator << (ostream &out, multiset<T> cont)
{
    typename multiset<T>::const_iterator itr = cont.begin();
    typename multiset<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T, template<typename ELEM, typename ALLOC=allocator<ELEM>> class CONT>
ostream& operator << (ostream &out, CONT<T> cont)
{
    typename CONT<T>::const_iterator itr = cont.begin();
    typename CONT<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator << (basic_ostream<CTy, CTr> &out, const T (&arr)[N])
{
     REP(i, 0, N)
        out<<arr[i]<<" ";
    out<<endl;

    return out;
}

template<typename T>
T gcd(T a, T b)
{
    T min_v = min(a, b);
    T max_v = max(a, b);

    while(min_v)
    {
        T temp = max_v % min_v;
        max_v = min_v;
        min_v = temp;
    }

    return max_v;
}

template<typename T>
T lcm(T a, T b)
{
    return (a*b) / gcd(a, b);
}

template<typename T>
T fast_exp_pow(T base, T exp, T mod)
{
    LL res = 1;

    while(exp)
    {
        if(exp&1)
        {
            res *= base;
            res %= mod;
        }

        exp >>= 1;
        base *= base;
        base %= mod;

    }

    return res % mod;
}

/*#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################*/

string word;
vector<int> primes;
int N, maxim;
int letters[30];
char result[1010];

bool is_prime(int num)
{
    for(auto elem: primes)
    {
        if(elem*elem > num)
            break;

        if(num%elem == 0)
            return false;
    }

    return true;
}

int main()
{
//    open_read1;
    cin>>word;
    N = word.size();

    for(auto elem: word)
    {
        ++letters[elem-'a'];

        if(letters[maxim] < letters[elem-'a'])
            maxim = elem - 'a';
    }

    FOR(num, 2, N)
    {
        if(is_prime(num))
            primes.pb(num);
    }

    ms(result, -1);

    for(int i=2; i<=N; i+=2)
    {
        if(letters[maxim])
        {
            result[i] = maxim;
            --letters[maxim];
        }

        else
        {
            printf("NO\n");
            return 0;
        }
    }

    REP(i, 1, primes.size())
    {
        if(primes[i]*2 <= N)
            FOR(j, 1, N/primes[i])
            {
                if(letters[maxim]  &&  result[primes[i]*j] == -1)
                {
                    result[primes[i]*j] = result[2];
                    --letters[maxim];
                }

                else if(result[primes[i]*j] == -1)
                {
                    printf("NO\n");
                    return 0;
                }
            }
    }

    FOR(i, 1, N)
    {
        if(result[i] == -1)
            REP(j, 0, 26)
                if(letters[j])
                {
                    result[i] = j;
                    --letters[j];
                    break;
                }
    }

    printf("YES\n");

    FOR(i, 1, N)
        printf("%c", result[i]+'a');
    printf("\n");

    return 0;
}


/*
ID: hepic
PROG: sabotage
LANG: C++11
*/
#include <bits/stdc++.h>

#define FOR(i, a, b) for(auto i=a; i<=b; ++i)
#define REP(i, a, b) for(auto i=a; i<b; ++i)
#define FORI(i, a, b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
#define REPI(i, a, b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
#define ALL(v) v.begin(),v.end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a, b) emplace_back(a, b)
#define fir first
#define sec second
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define type(x) typeid(x).name()
#define ms(arr, val) memset(arr, val, sizeof(arr))
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define PI acos(-1)
#define open_read1 freopen("a.txt", "r", stdin)
#define open_write1 freopen("b.xt", "w", stdout)
#define open_read freopen("team.in", "r", stdin)
#define open_write freopen("team.out", "w", stdout)

using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<double, double> PDD;
typedef pair<int, int> PII;
typedef pair<int, PII> PIPII;
typedef pair<PII, PII> PPIIPII;
typedef pair<LL, LL> PLL;
typedef pair<ULL, ULL> PUU;
typedef pair<LL, PLL> PLPLL;
typedef pair<PLL, PLL> PPLLPLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;

template<typename T, typename T1>
ostream& operator << (ostream &out, pair<T, T1> obj)
{
    out<<"("<<obj.first<<","<<obj.second<<")";
    return out;
}

template<typename T, typename T1>
ostream& operator << (ostream &out, map<T, T1> cont)
{
    typename map<T, T1>::const_iterator itr = cont.begin();
    typename map<T, T1>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T>
ostream& operator << (ostream &out, set<T> cont)
{
    typename set<T>::const_iterator itr = cont.begin();
    typename set<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T>
ostream& operator << (ostream &out, multiset<T> cont)
{
    typename multiset<T>::const_iterator itr = cont.begin();
    typename multiset<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T, template<typename ELEM, typename ALLOC=allocator<ELEM>> class CONT>
ostream& operator << (ostream &out, CONT<T> cont)
{
    typename CONT<T>::const_iterator itr = cont.begin();
    typename CONT<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator << (basic_ostream<CTy, CTr> &out, const T (&arr)[N])
{
     REP(i, 0, N)
        out<<arr[i]<<" ";
    out<<endl;

    return out;
}

template<typename T>
T gcd(T a, T b)
{
    T min_v = min(a, b);
    T max_v = max(a, b);

    while(min_v)
    {
        T temp = max_v % min_v;
        max_v = min_v;
        min_v = temp;
    }

    return max_v;
}

template<typename T>
T lcm(T a, T b)
{
    return (a*b) / gcd(a, b);
}

template<typename T>
T fast_exp_pow(T base, T exp, T mod)
{
    T res = 1;

    while(exp)
    {
        if(exp&1)
        {
            res *= base;
            res %= mod;
        }

        exp >>= 1;
        base *= base;
        base %= mod;

    }

    return res % mod;
}

/*#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################*/

#define SIZE 1010

string word, result;
int N;
int Parent[SIZE], Rank[SIZE];
int counts[30];
bool is_prime[SIZE];
vector<int> groups[SIZE];
vector<PII> groups_info;

int Find(int node) {
    return Parent[node] = (Parent[node] != node ? Find(Parent[node]) : node);
}

void Union(int nde_1, int nde_2) {
    if (Rank[nde_1] >= Rank[nde_2]) {
        Parent[nde_2] = nde_1;
        Rank[nde_1] += Rank[nde_2];
    } else {
        Parent[nde_1] = nde_2;
        Rank[nde_2] += Rank[nde_1];
    }
}

int main() {
    cin >> word;
    N = (int)word.size();

    FOR (i, 1, N) {
        ++counts[word[i - 1] - 'a'];

        Parent[i] = i;
        Rank[i] = 1;
    }

    ms(is_prime, true);

    FOR (i, 2, N) {
        if (is_prime[i]) {
            for (int j = i; j <= N; j += i) {
                is_prime[j] = false;

                int par_1 = Find(i);
                int par_2 = Find(j);

                if (par_1 != par_2) {
                    Union(par_1, par_2);
                }
            }
        }
    }

    FOR (i, 1, N) {
        int par = Find(i);

        if (par == i) {
            groups_info.eb(Rank[i], i);
        }

        groups[par].pb(i);
    }

    sort(ALL(groups_info), greater<PII>());
    result.resize(N);

    for (auto elem: groups_info) {
        int max_lt = 0;

        REP (i, 1, 26) {
            if (counts[i] > counts[max_lt]) {
                max_lt = i;
            }
        }

        if (counts[max_lt] < groups[elem.sec].size()) {
            printf("NO\n");
            return 0;
        }

        for (auto elem_1: groups[elem.sec]) {
            result[elem_1 - 1] = 'a' + max_lt;
        }

        counts[max_lt] -= groups[elem.sec].size();
    }

    printf("YES\n");
    cout << result << endl;

    return 0;
}


/*
ID: hepic
PROG: sabotage
LANG: C++11
*/
#include <bits/stdc++.h>

#define FOR(i, a, b) for(auto i=a; i<=b; ++i)
#define REP(i, a, b) for(auto i=a; i<b; ++i)
#define FORI(i, a, b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
#define REPI(i, a, b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
#define ALL(v) v.begin(),v.end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a, b) emplace_back(a, b)
#define fir first
#define sec second
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define type(x) typeid(x).name()
#define ms(arr, val) memset(arr, val, sizeof(arr))
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define SIZE 100010
#define MAXN 1000000009
#define NUM 40000
#define PI acos(-1)
#define open_read1 freopen("C:\\Users\\Hepic\\Desktop\\a.txt", "r", stdin)
#define open_write1 freopen("C:\\Users\\Hepic\\Desktop\\b.txt", "w", stdout)
#define open_read freopen("team.in", "r", stdin)
#define open_write freopen("team.out", "w", stdout)

using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<double, double> PDD;
typedef pair<int, int> PII;
typedef pair<int, PII> PIPII;
typedef pair<PII, PII> PPIIPII;
typedef pair<LL, LL> PLL;
typedef pair<ULL, ULL> PUU;
typedef pair<LL, PLL> PLPLL;
typedef pair<PLL, PLL> PPLLPLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;

template<typename T, typename T1>
ostream& operator << (ostream &out, pair<T, T1> obj)
{
    out<<"("<<obj.first<<","<<obj.second<<")";
    return out;
}

template<typename T, typename T1>
ostream& operator << (ostream &out, map<T, T1> cont)
{
    typename map<T, T1>::const_iterator itr = cont.begin();
    typename map<T, T1>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T>
ostream& operator << (ostream &out, set<T> cont)
{
    typename set<T>::const_iterator itr = cont.begin();
    typename set<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T>
ostream& operator << (ostream &out, multiset<T> cont)
{
    typename multiset<T>::const_iterator itr = cont.begin();
    typename multiset<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T, template<typename ELEM, typename ALLOC=allocator<ELEM>> class CONT>
ostream& operator << (ostream &out, CONT<T> cont)
{
    typename CONT<T>::const_iterator itr = cont.begin();
    typename CONT<T>::const_iterator ends = cont.end();

    for(; itr!=ends; ++itr)
        out<<*itr<<" ";
    out<<endl;

    return out;
}

template<typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator << (basic_ostream<CTy, CTr> &out, const T (&arr)[N])
{
     REP(i, 0, N)
        out<<arr[i]<<" ";
    out<<endl;

    return out;
}

template<typename T>
T gcd(T a, T b)
{
    T min_v = min(a, b);
    T max_v = max(a, b);

    while(min_v)
    {
        T temp = max_v % min_v;
        max_v = min_v;
        min_v = temp;
    }

    return max_v;
}

template<typename T>
T lcm(T a, T b)
{
    return (a*b) / gcd(a, b);
}

template<typename T>
T fast_exp_pow(T base, T exp, T mod)
{
    LL res = 1;

    while(exp)
    {
        if(exp&1)
        {
            res *= base;
            res %= mod;
        }

        exp >>= 1;
        base *= base;
        base %= mod;

    }

    return res % mod;
}

/*#################################################################################################################
#################################################################################################################
#################################################################################################################
#################################################################################################################*/

string word;
vector<int> primes;
vector<PII> prime_chain;
priority_queue<PII> letter_chain;
int N, cnt;
int letters[30];
char result[1010];

bool is_prime(int num)
{
    for(auto elem: primes)
    {
        if(elem*elem > num)
            break;

        if(num%elem == 0)
            return false;
    }

    return true;
}

int main()
{
//    open_read1;
    cin>>word;
    N = word.size();

    for(auto elem: word)
        ++letters[elem-'a'];

    REP(i, 0, 26)
        letter_chain.push(mp(letters[i], i));

    FOR(num, 2, N)
    {
        if(is_prime(num))
            primes.pb(num);
    }

    for(auto elem: primes)
    {
        cnt = 0;

        FOR(i, 1, elem)
        {
            if(elem*i > N)
                break;

            ++cnt;
        }

        prime_chain.eb(cnt, elem);
    }

    ms(result, -1);
    sort(ALL(prime_chain), greater<PII>());

    for(auto elem: prime_chain)
    {
        int chain_len = elem.fir;
        int prm = elem.sec;
        int much = letter_chain.top().fir;
        int lt = letter_chain.top().sec;

        letter_chain.pop();

        if(chain_len > much)
        {
            printf("NO\n");
            return 0;
        }

        much -= chain_len;
        letters[lt] -= chain_len;

        if(much)
            letter_chain.push(mp(much, lt));

        FOR(i, 1, prm)
        {
            if(prm*i > N)
                break;

            result[prm*i] = lt;
        }
    }

    FOR(i, 1, N)
    {
        if(result[i] == -1)
            REP(j, 0, 26)
                if(letters[j])
                {
                    result[i] = j;
                    --letters[j];
                    break;
                }
    }

    printf("YES\n");

    FOR(i, 1, N)
        printf("%c", result[i]+'a');
    printf("\n");

    return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod=1e9+7;

int x,n,a[1000000],b,f=1;
int color[100000];
vector < int > v;
vector < pair<int,char> > vec;
map <int,int> ans;
bool ok[200000];
int lol[1304][1304];
void r(){
int N=1200;
for(int i=2;i<=N;i+=2)
    ok[i]=1;
for(int i=3;i<=N;i+=2){
    if(!ok[i])
        for(int j=i*i;j<=N;j+=i)
            ok[j]=1;
}
v.push_back(2);
for(int i=3;i<=N;i+=2)
if(!ok[i])v.push_back(i);
}

main()
{
    string s;
    cin >> s;

    r();
    //cout << v.size();
    for(int i=0;i<s.size();i++)
        a[s[i]-'a']++;
    for(int i=0;i<='z'-'a';i++)
    vec.push_back({a[i],char(i+'a')});

    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(auto i:v)
    for(auto j:v)
    if(i==j||s.size()>=i*j)
        lol[i][j]=lol[j][i]=1;

    for(auto i:v)
    for(int j=0;j<v.size();j++)
    if(v[j]<=i&&lol[i][v[j]])
    {
        for(int k=i;k<=s.size();k+=i)
            color[k]=j+2;
        break;
    }

    color[1]=196;
    for(int i=1;i<=s.size();i++)
        ans[color[i]]++;

    vector <pair<int,int> > re;
        for(auto i:ans)
            re.push_back({i.second,i.first});
    sort(re.begin(),re.end());
    reverse(re.begin(),re.end());
    int cc=0;
    for(auto i:re)
    {
        if(vec[0].first>=i.first){
            vec[0].first-=i.first;
            for(int j=1;j<=s.size();j++)
                if(j%v[i.second-2]==0)
                    s[j-1]=vec[0].second;
            cc++;
            if(i.second==196)
                s[0]=vec[0].second;
            sort(vec.begin(),vec.end());
            reverse(vec.begin(),vec.end());
        }
        else {cout << "NO";return 0;}
    }
    cout << "YES\n";
    cout << s;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod=1e9+7;

int x,n,a[1000000],b,f=1;
int color[100000];
vector < int > v;
vector < pair<int,char> > vec;
map <int,int> ans;
bool ok[200000];
int lol[1304][1304];
void r(){
int N=1200;
for(int i=2;i<=N;i+=2)
    ok[i]=1;
for(int i=3;i<=N;i+=2){
    if(!ok[i])
        for(int j=i*i;j<=N;j+=i)
            ok[j]=1;
}
}

main()
{
    string s;
    cin >> s;

    r();
    //cout << v.size();
    //cout << s.size();
    for(int i=0;i<s.size();i++)
        a[s[i]-'a']++;
    for(int i=0;i<='z'-'a';i++)
    vec.push_back({a[i],char(i+'a')});

    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());

    string t=s;
    n=s.size();
    for(int i=2;i<=n;i++)
        if(i<=n/2||ok[i])
    {
        t[i-1]=vec[0].second;
        vec[0].first--;
        if(vec[0].first<0){
            cout << "NO";
            return 0;
        }
    }
    string kek;
    for(auto i:vec)
        {
            for(int j=0;j<i.first;j++)
                kek+=i.second;
        }

    cout << "YES\n";
    int y=0;
    //cout << kek;
    for(int i=1;i<=n;i++)
        if(i>=2&&i<=n/2||ok[i])
            cout << t[i-1];
        else {cout << kek[y];y++;}

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod=1e9+7;

int x,n,a[1000000],b,f=1;
int color[100000];
vector < int > v;
vector < pair<int,char> > vec;
map <int,int> ans;
bool ok[200000];
int lol[1004][1004];
void r(){
int N=1000;
for(int i=2;i<=N;i+=2)
    ok[i]=1;
for(int i=3;i<=N;i+=2){
    if(!ok[i])
        for(int j=i*i;j<=N;j+=i)
            ok[j]=1;
}
v.push_back(2);
for(int i=3;i<=N;i+=2)
if(!ok[i])v.push_back(i);
}

main()
{
    string s;
    cin >> s;

    r();
    //cout << v[1];
    for(int i=0;i<s.size();i++)
        a[s[i]-'a']++;
    for(int i=0;i<='z'-'a';i++)
    vec.push_back({a[i],char(i+'a')});

    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(auto i:v)
    for(auto j:v)
    if(i==j||s.size()>=i*j)
        lol[i][j]=lol[j][i]=1;

    for(auto i:v)
    for(int j=0;j<v.size();j++)
    if(v[j]<=i&&lol[i][v[j]])
    {
        for(int k=i;k<=s.size();k+=i)
            color[k]=j+2;
        break;
    }
    color[1]=1;
    for(int i=1;i<=s.size();i++)
        ans[color[i]]++;

    vector <pair<int,int> > re;
        for(auto i:ans)
            re.push_back(i);
    reverse(re.begin(),re.end());
    for(auto i:re)
    {
        if(vec[0].first>=i.second){
            vec[0].first-=i.second;
            for(int j=1;j<=s.size();j++)
                if(j%vec[0].second==0)
                    s[j-1]=vec[0].second;

            sort(vec.begin(),vec.end());
            reverse(vec.begin(),vec.end());
        }
        else {cout << "NO";return 0;}
    }
    cout << "YES\n";
    cout << s;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod=1e9+7;

int x,n,a[1000000],b,f=1;
int color[100000];
vector < int > v;
vector < pair<int,char> > vec;
map <int,int> ans;
bool ok[200000];
int lol[1304][1304];
void r(){
int N=1200;
for(int i=2;i<=N;i+=2)
    ok[i]=1;
for(int i=3;i<=N;i+=2){
    if(!ok[i])
        for(int j=i*i;j<=N;j+=i)
            ok[j]=1;
}
v.push_back(2);
for(int i=3;i<=N;i+=2)
if(!ok[i])v.push_back(i);
}

main()
{
    string s;
    cin >> s;

    r();
    //cout << v.size();
    for(int i=0;i<s.size();i++)
        a[s[i]-'a']++;
    for(int i=0;i<='z'-'a';i++)
    vec.push_back({a[i],char(i+'a')});

    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(auto i:v)
    for(auto j:v)
    if(i==j||s.size()>=i*j)
        lol[i][j]=lol[j][i]=1;

    for(auto i:v)
    for(int j=0;j<v.size();j++)
    if(v[j]<=i&&lol[i][v[j]])
    {
        for(int k=i;k<=s.size();k+=i)
            color[k]=j+2;
        break;
    }

    color[1]=197;
    for(int i=1;i<=s.size();i++)
        ans[color[i]]++;

    vector <pair<int,int> > re;
        for(auto i:ans)
            re.push_back({i.second,i.first});
    sort(re.begin(),re.end());
    reverse(re.begin(),re.end());
    for(auto i:re)
    {
        if(vec[0].first>=i.first){
            vec[0].first-=i.first;
            for(int j=1;j<=s.size();j++)
                if(j%v[i.second-2]==0)
                    s[j-1]=vec[0].second;

            sort(vec.begin(),vec.end());
            reverse(vec.begin(),vec.end());
        }
        else {cout << "NO";return 0;}
    }
    cout << "YES\n";
    cout << s;

}