#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int a[10];
  cin >> s;
  memset(a, 0, sizeof(a));
  for (int i = (0); (i) < (s.length()); (i)++) a[int(s[i]) - 48]++;
  int k = 0, l = 0, m = 0;
  for (int i = (1); (i) < (5); (i)++) k += min(a[i], a[10 - i]);
  k += a[5];
  for (int i = (1); (i) < (5); (i)++) l += min(a[i], a[9 - i]);
  m = min(a[0], a[9]);
  if (k == 0) {
    for (int j = (1); (j) < (10); (j)++)
      for (int t = (0); (t) < (a[j]); (t)++) cout << j;
    for (int t = (0); (t) < (a[0]); (t)++) cout << 0;
    cout << endl;
    for (int j = (1); (j) < (10); (j)++)
      for (int t = (0); (t) < (a[j]); (t)++) cout << j;
    for (int t = (0); (t) < (a[0]); (t)++) cout << 0;
    cout << endl;
    return 0;
  }
  int mm = -1;
  int d = 0;
  for (int j = (1); (j) < (6); (j)++) {
    int a1[10], a2[10];
    for (int i = (0); (i) < (10); (i)++) {
      a1[i] = a[i];
      a2[i] = a[i];
    }
    if (a[j] == 0 || a[10 - j] == 0) continue;
    a1[j]--;
    a2[10 - j]--;
    int m = 0;
    for (int t = (0); (t) < (10); (t)++) m += min(a1[t], a2[9 - t]);
    m += max(a[0] - a[9], 0);
    if (m > mm) {
      mm = m;
      d = j;
    }
  }
  int a1[10], a2[10];
  for (int i = (0); (i) < (10); (i)++) {
    a1[i] = a[i];
    a2[i] = a[i];
  }
  a1[d]--;
  a2[10 - d]--;
  vector<int> r1, r2;
  for (int i = (0); (i) < (max(a[0] - a[9], 0)); (i)++) {
    r1.push_back(0);
    r2.push_back(0);
  }
  a1[0] -= max(a[0] - a[9], 0);
  a2[0] -= max(a[0] - a[9], 0);
  r1.push_back(d);
  r2.push_back(10 - d);
  for (int i = (0); (i) < (10); (i)++) {
    for (int j = (0); (j) < (min(a1[i], a2[9 - i])); (j)++) {
      r1.push_back(i);
      r2.push_back(9 - i);
    }
    int r = min(a1[i], a2[9 - i]);
    a1[i] -= r;
    a2[9 - i] -= r;
  }
  for (int i = (0); (i) < (10); (i)++)
    for (int j = (0); (j) < (a1[i]); (j)++) r1.push_back(i);
  for (int i = (0); (i) < (10); (i)++)
    for (int j = (0); (j) < (a2[i]); (j)++) r2.push_back(i);
  for (int i = r1.size() - 1; i >= 0; i--) cout << r1[i];
  cout << endl;
  for (int i = r2.size() - 1; i >= 0; i--) cout << r2[i];
  return 0;
}
