/************************************
 *  Event  :      Interuni 2009, Vologda
 *  Problem:      Reverse
 *  Author:       Pavel Kuznetsov
 *  Last update:  2000.02.25 22:02
 ************************************
*/

#include <stdio.h>
#include <memory.h>
#include <map> 
#include <set> 
#include <queue> 
#include <bitset> 
#include <valarray> 
#include <complex> 
#include <iostream> 
#include <sstream> 
#include <cmath> 
#include <algorithm> 
#include <string> 
#include <cassert> 

#pragma comment(linker,"/STACK:20000000")

using namespace std;

// prewritten code

#define Size(x) (int)(x).size()
#define For(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define Ford(i,a,b) for(int i=(int)(a);i>=(int)(b);--i) 
#define RepV(i,v) for (int i=0;i<Size(v);++i)
#define All(c) (c).begin(),(c).end()
#define Fill(a,b) memset(&a,b,sizeof(a))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Abs(a) ((a)<0?-(a):(a))
#define VVI vector<vector<int> >
#define VI vector<int>
#define VVS vector<vector<string> >
#define VS vector<string>
#define ForEach(it,a) for (typeof((a).begin()) it=(a).begin(); it!=(a).end(); ++it)
#define DBG(x) cout << #x <<" = "<< x << endl;
#define DBGA(x) {cout << #x <<": "; for (int i=0; i<(int)sizeof(x)/(int)sizeof(x[0]); ++i) cout<<x[i]<<' '; cout<<endl;}
#define DBGV(x) {cout << #x <<": "; for (int i=0; i<(int)Size(x); ++i) cout<<x[i]<<' '; cout<<endl;}

const string problem_name = "reverse";

const int MAX_LEN = 100101;

char num[MAX_LEN], res[MAX_LEN];
int cache[2<<20], len;

int can(int l, int r, char carry_in, char carry_out){
	if (l-1==r) return carry_in==carry_out;
	int key = l|(carry_in<<18)|(carry_out<<19);
	if (cache[key] != -1) return cache[key];
	int &res = cache[key];
	res=0;
	int bottom = l == 0 ? 1 : 0;
	if (l == r){
		for(int i=9; i>=bottom; --i)
			if ((i+i+carry_in)%10 == num[l] && (i+i+carry_in)/10 == carry_out)
				return res = 1|(i<<1)|(i<<5);
	} else{
	  for(int i=9; i>=bottom; --i) {
	    if (res) break;
	    for (int j=0; j<=9; ++j) if ((i+j+carry_in)%10 == num[r]) {
		    if ((i+j)%10 == num[l] && (i+j)/10 == carry_out && can(l+1,r-1,(i+j+carry_in)/10,0)){
			    return res = 1|(i<<1)|(j<<5);
		    } else if ((i+j+1)%10 == num[l] && (i+j+1)/10 == carry_out && can(l+1,r-1,(i+j+carry_in)/10,1)){
			    return res = 1|(i<<1)|(j<<5);
		    }
		    break;
	    }
	  }
	}   
	return res;
}

bool solve(){
	Fill(cache,-1);
	if (can(0,len-1,0,0)&1) {
		int l=0, r=len-1, carry_in=0, carry_out=0, key;
		while (l<=r){
			key = l|(carry_in<<18)|(carry_out<<19);
			res[l]=(cache[key]>>1)&15;
			res[r]=(cache[key]>>5)&15;
			carry_in = (res[l]+res[r]+carry_in)/10;
			if ((res[l]+res[r])%10 == num[l]) carry_out=0;
			else carry_out=1;
			res[l]+='0';
			if (l!=r) res[r] +='0';
			++l; --r;
		}
		return true;
	}
	
	Fill(cache,-1);
	if (num[0] == 1 && (can(1,len-1,0,1)&1)) {
		int l=1, r=len-1, carry_in=0, carry_out=1, key;
		while (l<=r){
			key = l|(carry_in<<18)|(carry_out<<19);
			res[l-1]=(cache[key]>>1)&15;
			res[r-1]=(cache[key]>>5)&15;
			carry_in = (res[l-1]+res[r-1]+carry_in)/10;
			if ((res[l-1]+res[r-1])%10 == num[l]) carry_out=0;
			else carry_out=1;
			res[l-1]+='0';
			if (l!=r) res[r-1] +='0';
			++l; --r;
		}
		return true;
	}
	
	return false;
}

int main(){
//	freopen((problem_name+".in").c_str(),"rt",stdin);
//	freopen((problem_name+".out").c_str(),"wt",stdout);
	
	//gets(num);
	scanf("%s", num);
	len = strlen(num);
	
	assert(len > 0 && len <= MAX_LEN);
	For(i,0,len-1) {
		assert(num[i]>='0' && num[i]<='9');
		num[i]-='0';
	}
	assert(num[0]);
	
	if (!solve()) printf("0");
	else printf("%s",res);
	
	return 0;
}
