#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 14;
char s[MAXN + 1];
int n;
int diff[MAXN];
int mdiff[MAXN];
long long p[MAXN + 1];
int decode(char c) { return isdigit(c) ? c - '0' : c - 'a' + 10; }
char encode(int x) { return x < 10 ? '0' + x : 'a' + x - 10; }
int mdiffsum[1 << MAXN];
long long dp[1 << MAXN];
long long solvefixedcarry() {
  for (int i = (0); i < (1 << n); ++i) dp[i] = -1;
  dp[0] = 0;
  mdiffsum[0] = 0;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (1 << i); ++j)
      mdiffsum[j + (1 << i)] = mdiffsum[j] + mdiff[i];
  for (int i = (0); i < (1 << n); ++i)
    if (dp[i] != -1) {
      int a = mdiffsum[i];
      for (int j = (0); j < (n); ++j)
        if ((i & (1 << j)) == 0) {
          int b = a + mdiff[j];
          if (b < 0 || b >= 16) continue;
          int ii = i | (1 << j);
          long long nval = dp[i] + p[j] * a;
          if (dp[ii] != -1 && dp[ii] < nval) continue;
          dp[ii] = nval;
        }
    }
  return dp[(1 << n) - 1];
}
void run() {
  scanf("%s", s);
  n = strlen(s);
  reverse(s, s + n);
  for (int i = (0); i < (n); ++i) diff[i] = decode(s[i]);
  p[0] = 1;
  for (int i = (0); i < (n); ++i) p[i + 1] = p[i] * 16;
  long long ret = -1;
  for (int carrymask = (0); carrymask < (1 << (n - 1)); ++carrymask) {
    int sum = 0;
    bool ok = true;
    for (int i = (0); i < (n); ++i) {
      mdiff[i] = diff[i];
      if (carrymask & (1 << i)) mdiff[i] -= 16;
      if (i != 0 && (carrymask & (1 << (i - 1)))) mdiff[i] += 1;
      sum += mdiff[i];
      if (mdiff[i] <= -16 || mdiff[i] >= 16) ok = false;
    }
    if (!ok || sum != 0) continue;
    long long cur = solvefixedcarry();
    if (cur != -1 && (ret == -1 || cur < ret)) ret = cur;
  }
  if (ret == -1) {
    printf("NO\n");
    return;
  }
  for (int i = (0); i < (n); ++i) s[i] = encode(ret / p[i] % 16);
  reverse(s, s + n);
  printf("%s\n", s);
}
int main() {
  run();
  return 0;
}
