#include <bits/stdc++.h>
template <typename T>
using Vector2D = std::vector<std::vector<T>>;
template <typename T>
using Vector3D = std::vector<Vector2D<T>>;
using PairInt = std::pair<int, int>;
using PairInt64 = std::pair<int64_t, int64_t>;
using MapInt = std::map<int, int>;
using MMapInt = std::multimap<int, int>;
using MMapInt64 = std::multimap<int64_t, int64_t>;
using UMapIntString = std::unordered_map<int, std::string>;
using SetInt = std::set<int>;
using SetPairInt64 = std::set<PairInt64>;
using VectorInt = std::vector<int>;
using VectorInt2D = Vector2D<int>;
using VectorInt64 = std::vector<int64_t>;
using VectorUInt64 = std::vector<uint64_t>;
using VectorInt642D = Vector2D<int64_t>;
using VectorChar = std::vector<char>;
using VectorChar2D = Vector2D<char>;
using VectorString = std::vector<std::string>;
using QueuePairInt = std::queue<PairInt>;
using QueueInt = std::queue<int>;
using VectorPairInt = std::vector<PairInt>;
using VectorPairInt64 = std::vector<PairInt64>;
using VectorPairInt2D = Vector2D<PairInt>;
using SetInt = std::set<int>;
using MSetInt = std::multiset<int>;
using UMapChar = std::map<char, int>;
using ListInt = std::list<int>;
using VectorListInt = std::vector<ListInt>;
using VectorDouble = std::vector<double>;
const PairInt bad_digs = {-1, -1};
const auto s09 = VectorPairInt{{0, 0}, {1, 0}, {1, 1}, {3, 0}, {2, 2},
                               {5, 0}, {3, 3}, {7, 0}, {4, 4}, {9, 0}};
const auto s10 = VectorPairInt{{5, 5}, {9, 2}, {6, 6}, {9, 4}, {7, 7},
                               {9, 6}, {8, 8}, {9, 8}, {9, 9}, bad_digs};
PairInt check_digs(const VectorPairInt& s, int dback, int dfront, int& n,
                   int& p) {
  auto digs = s[dback];
  int digs_sum = digs.first + digs.second;
  if (digs_sum == dfront || digs_sum + 1 == dfront) {
    n = dfront - digs_sum;
    p = (digs_sum + p >= 10) ? 1 : 0;
  } else {
    digs = bad_digs;
  }
  return digs;
}
PairInt check_equal(const VectorPairInt& s, int dback, int dfront, int p) {
  auto digs = s[dback];
  auto digs_sum = digs.first + digs.second;
  if (digs_sum + p != dfront || digs.first != digs.second) {
    digs = bad_digs;
  }
  return digs;
}
bool next_step(const std::string& num, std::string& ans, int i, int j, int& n,
               int& p) {
  if (i > j) {
    return false;
  }
  int dback = num[j] - '0' - p;
  if (dback < 0) {
    dback = 9;
  }
  int dfront = n * 10 + (num[i] - '0');
  auto digs = bad_digs;
  if (i == j) {
    digs = check_equal(s09, dback, dfront, p);
    if (digs == bad_digs) {
      digs = check_equal(s10, dback, dfront, p);
    }
  } else {
    int lastn = n;
    int lastp = p;
    digs = check_digs(s09, dback, dfront, n, p);
    if (digs == bad_digs) {
      digs = check_digs(s10, dback, dfront, n, p);
    }
    if (digs != bad_digs && i + 1 == j) {
      int res = (num[j] - '0') + (num[i] - '0') * 10 + lastn * 100;
      int digs_sum = digs.first + digs.second;
      if (digs_sum + digs_sum * 10 + lastp != res) {
        digs = bad_digs;
      }
    }
  }
  if (digs == bad_digs) {
    ans = "0";
    return false;
  } else {
    ans[i] = digs.first + '0';
    ans[j] = digs.second + '0';
    return true;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::string num;
  std::cin >> num;
  int sz = num.length();
  std::string ans(sz, '0');
  int n = 0;
  int p = 0;
  for (int i = 0, j = sz - 1; next_step(num, ans, i, j, n, p); ++i, --j)
    ;
  if (ans[0] == '0' && num[0] == '1' && sz > 1) {
    num.erase(0, 1);
    --sz;
    ans = std::string(sz, '0');
    n = 1;
    p = 0;
    for (int i = 0, j = sz - 1; next_step(num, ans, i, j, n, p); ++i, --j)
      ;
  }
  if (ans[0] == '0') {
    ans = "0";
  }
  std::cout << ans;
  return 0;
}
