#include <bits/stdc++.h>
using namespace std;
const long long inf = 3e18 + 20;
const int N = 14 + 2, MASK = (1 << 14) + 20;
int n, a[N], b[N], sum[MASK];
long long dp[MASK];
string s;
inline int char_to_int(char c) {
  if (c <= '9') return c - '0';
  return c - 'a' + 10;
}
inline char int_to_char(int x) { return (x < 10 ? x + '0' : x - 10 + 'a'); }
inline string int_to_hex(long long x, int n) {
  string s = "";
  while (n--) {
    s += int_to_char(x & 15);
    x >>= 4;
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long ans = inf;
  cin >> s;
  n = ((int)s.size());
  for (int i = 0; i < n; i++) {
    a[i] = char_to_int(s[n - 1 - i]);
  }
  int cnt = 0;
  for (int mask = 0; mask < (1 << (n - 1)); mask++) {
    for (int i = 0; i < n; i++) b[i] = a[i];
    for (int i = 0; i < n - 1; i++) {
      if (((mask) >> (i)&1)) b[i] -= 16, b[i + 1]++;
    }
    int _sum = 0;
    bool ok = 1;
    for (int i = 0; i < n; i++) _sum += b[i], ok &= (b[i] < 16);
    if (_sum != 0 || !ok) continue;
    for (int mask = 1; mask < (1 << n); mask++) {
      sum[mask] = sum[mask - (mask & -mask)] + b[__builtin_ctz(mask & -mask)];
    }
    for (int mask = 1; mask < (1 << n); mask++) dp[mask] = inf;
    for (int mask = 1; mask < (1 << n); mask++) {
      for (int i = 0; i < n; i++) {
        if (!((mask) >> (i)&1)) continue;
        if (dp[mask ^ (1 << i)] != inf && sum[mask] >= 0 && sum[mask] < 16) {
          dp[mask] =
              min(dp[mask], dp[mask ^ (1 << i)] +
                                ((long long)sum[mask ^ (1 << i)] << 4 * i));
        }
      }
    }
    ans = min(ans, dp[(1 << n) - 1]);
  }
  if (ans == inf)
    cout << "NO\n";
  else
    cout << int_to_hex(ans, n) << '\n';
}
