const fi='palin.inp';
fo='palin.out';
max=round(1e6);
type bignum=array [1..max] of longint;
var a,b: bignum;
s:ansistring;
t,i,dem:longint;
function check(a:bignum):boolean;
var c,t:longint;
begin
t:=length(s);
for c:=1 to t div 2 do
if a[1+c-1]<>a[t-c+1] then exit(false);
exit(true);
end;
begin
assign(input,fi);
reset(input);
read(s);
close(input);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
dem:=0;
t:=length(s);
b[t]:=1;
for i:=1 to t do
a[i]:= ord(s[i])-48;
while not check(a) do
begin
for i:=t downto 1 do
begin
a[i]:=(a[i]+b[i]) mod 10;
if a[i]=10 then inc(a[i-1]);
end;
end;
assign(output,fo);
rewrite(output);
for i:=1 to t do
write(a[i]);
close(output);
end.