bcdef
abbbc
 z
y
 reddit
abcdef
 abc
aaa
 y
z
 cbxz
aaaa

bccdb
 z
 dfdeed
 aab
 y
 abac

#include <bits/stdc++.h>
using namespace std;
string help(string &first, string &second) {
  string re = first + second;
  int f = first.size() - 1;
  int s = second.size() - 1;
  for (int i = re.size() - 1; i >= 0; i--) {
    int order = i - (re.size() - 1);
    if (order % 2 == 0) {
      re[i] = first[f];
      f--;
    } else {
      re[i] = second[s];
      s--;
    }
  }
  return re;
}
int main() {
  string o = "1789", i = "4567";
  sort(o.begin(), o.end());
  sort(i.rbegin(), i.rend());
  int n = o.size();
  i = i.substr(0, n / 2);
  o = o.substr(0, (n / 2) + n % 2);
  string re = o + i;
  int oi = 0;
  int ii = 0;
  for (int k = 0; k < n; k++) {
    if (k % 2 == 0) {
      if (o[oi] < i[oi]) {
        re[k] = o[oi];
        oi++;
      } else {
        re = k == 0 ? "" : re.substr(0, k);
        o = o.substr(oi);
        i = i.substr(ii);
        re += help(o, i);
        break;
      }
    } else {
      if (o[oi] < i[ii]) {
        re[k] = i[ii];
        ii++;
      } else {
        re = k == 0 ? "" : re.substr(0, k);
        o = o.substr(oi);
        i = i.substr(ii);
        re += help(i, o);
        break;
      }
    }
  }
  cout << re;
}
