uses crt;
var n:longword;
function solve(n:longword):byte;
var v,min,d:byte;
begin
v:=0;min:=9;d:=0;
while n<>0 do
begin
if n mod 10 <> 0 then
if n mod 10 <= min then
begin
min:=n mod 10;
v:=d;
end;
inc(d);n:=n div 10;
end;
exit(v);
end;
begin
clrscr;
readln(n);
writeln(solve(n));
readkey;
end.
==============================
uses crt,math;
var n:longword;
function solve(n:longword):byte;
var mi,ma,m:byte;
begin
mi:=9;ma:=0;
while n<>0 do
begin
m:=n mod 10;
mi:=min(mi,m);
ma:=max(ma,m);
n:=n div 10;
end;
exit(ma-mi);
end;
begin
clrscr;
readln(n);
writeln(solve(n));
readkey;
end.
===============================
uses crt;
var n:longword;
function solve(n:longword):boolean;
var i:byte;
s:string;
begin
str(n,s);
for i:=1 to length(s) div 2 do
if s[i] <> s[length(s)-i+1] then exit(false);
exit(true);
end;
begin
clrscr;
readln(n);
writeln(solve(n));
readkey;
end.