var	s,h,m:ansistring;
	dem,a,h2,m2:longint;
begin
	readln(s);
	h:=copy(s,1,2);
	m:=copy(s,4,2);
	if h[2]=m[1] then
		if h[1]=m[2] then
		begin
			writeln(0);
			halt;
		end;
	val(h,h2,a);
	val(m,m2,a);
	dem:=0;
	while ( (h2 mod 10)*10 + (h2 div 10) <> m2) do
	begin
		inc(dem);
		inc(m2);
		if m2=60 then
		begin
			inc(h2);
			m2:=0;
			if h2=24 then h2:=0;
		end;
	end;
	writeln(dem);
end.

var a,b,code:longint;
    Sx,St:String;

function kt(a,b:longint):longint;
var res:longint;
begin
    res:=0;
    repeat
        if b=a mod 10*10+a div 10 then break;
        inc(b);
        if b=60 then
        begin
            inc(a);
            if a=24 then a:=0;
            b:=0;
        end;
        inc(res);
    until res=0;
    exit(res);
end;

begin
    readln(St);
    Sx:=copy(St,1,2);
    val(Sx,a,code);
    Sx:=copy(St,4,2);
    val(Sx,b,code);
    Writeln(kt(a,b));
end.

Var

	m, h: LongInt;

	result: LongInt;

Procedure getData();

	Var

		a: Char;

	Begin

		read(a);

		h:= ord(a) - 48;

		read(a);

		h:= h * 10 + ord(a) - 48;

		read(a);

		read(a);

		m:= ord(a) - 48;

		read(a);

		m:= m * 10 + ord(a) - 48;

	End;

Procedure iterate();

	function palindrome(Const h, m: LongInt): Boolean;

		Begin

			If (h div 10 = m mod 10) and (h mod 10 = m div 10) Then
			Begin

				palindrome:= true;

			End
			Else
			Begin

				palindrome:= false;

			End;

		End;

	Begin

		result:= 0;

		While not palindrome(h, m) do
		Begin

			result:= result + 1;

			m:= m + 1;

			If m = 60 Then
			Begin

				h:= h + 1;

				m:= 0;

			End;

			If h = 24 Then
			Begin

				h:= 0;

			End;

		End;

	End;

Begin

	getData();

	iterate();

	writeLn(result);

End.

Var t1,t2,t:string;
    e,f,c2,i,c,k:longint;
begin
     readln(t2);
     t1:=copy(t2,1,2);
     delete(t2,1,3);
     val(t2,c2,f);
     val(t1,c,f);
     t:='';
     for i:=length(t1)downto 1 do
      t:=t+t1[i];
      t1:=t;
      k:=0;
      if length(t1)<2 then t1:=t1+'0';
      while (t1<>t2) do
      begin
      c2:=c2+1;
      if c2=60 then begin
                     c2:=0;
                     c:=c+1;
                     end;
      if c>23 then c:=0;
      str(c2,t2);
      str(c,t1);
      t:='';
      for i:=length(t1) downto 1 do
      t:=t+t1[i];
      t1:=t;
      if length(t1)<2 then t1:=t1+'0';
      if length(t2)<2 then t2:='0'+t2;
      k:=k+1;
      end;
      writeln(k);
end.

var
   n,i,j,ch1,min1,k ,e,l,m,r,b: longint;
   s,ch,min,z,p1,p2 : string;
begin
     b := 0;
     readln(s);
     for i := 1 to Length(s) do
     begin
          if s[i] = ':' then
          begin
          delete(s,i,1);
          break;
          end;
     end;
     ch := ch + s[1] + s[2];
     min := min + s[3] + s[4];
     val(ch,ch1,e);
     val(min,min1,e);
     s := '';
     s := s + ch + min;
     for j := 1 to (Length(s) div 2) do
          begin
               if s[j] = s[Length(s)-r] then
               begin
               inc(l);
               inc(r);
               end
               else
               break;
          end;
          if l = (Length(s) div 2)then
          begin
               writeln(k);
               exit;
          end;
          l := 0;
          r := 0;
     while m <> 7 do
     begin
          inc(min1);
          inc(k);
          if min1 = 60 then
          begin
               min := '00';
               min1 := 0;
               inc(ch1);
          end;
          if ch1 = 24 then
          begin
               ch := '00';
               ch1 := 0;
          end;
          str(ch1,p1);
          str(min1,p2);
          if ch1 < 10 then
          begin
               ch := '0' + p1;
          end
          else
          begin
               ch := p1;
          end;
          if min1 < 10 then
          begin
               min := '0' + p2;
          end
          else
          begin
               min := p2;
          end;
          z := z + ch + min;
          p1 := '';
          p2 := '';
          for j := 1 to (Length(z) div 2) do
          begin
               if z[j] = z[Length(z)-b] then
               begin
               inc(l);
               inc(b);
               end
               else
               begin
               break;
               b := 0;
               end;
          end;
          b := 0;
          if l = (Length(z) div 2)then
          begin
               writeln(k);
               exit;
          end;
          b := 0;
          l := 0;
          z := '';
     end;

end.

const fi='';
      fo='';
var  c:array [1..5] of char;
     a:array [1..4] of longint;
     h,m:longint;
function tim(a,b:longint):longint;
var x,y,z:longint;
begin
   y:=a;
   if a=24 then y:=0;
   x:=y mod 10;
   y:=y div 10;
   for z:=b to 59 do if z=10*x+y then exit(a*60+z-h*60-m);
   exit(tim(a+1,0));
end;
procedure doc;
var i:longint;
begin
  assign(input,fi);reset(input);
  assign(output,fo);rewrite(output);
  for i:=1 to 5 do read(c[i]);
  val(c[1],a[1]);val(c[2],a[2]);val(c[4],a[3]);val(c[5],a[4]);
  h:=a[1]*10+a[2];m:=a[3]*10+a[4];
  write(tim(h,m));
  close(input);close(output);
end;
begin
  doc;
end.

var a,b,c,d,s,o:longint;strok:string;
BEGIN
readln(strok);
val(strok[1],a,o);
val(strok[2],b,o);
val(strok[4],c,o);
val(strok[5],d,o);
while (A<>D)or(b<>c) do
begin
if (a=d)and(b=c)then break;
s:=s+1;
d:=d+1;
if d=10 then begin d:=0;c:=c+1;end;
if c=6  then begin c:=0;b:=b+1;end;
if b=10  then begin b:=0;a:=a+1;end;
if (a=2)and(b=4)then begin a:=0;b:=0;end;
end;
writeln(s);
end.

program O_O;
type
        ll=longint;
var
        a,b,c,d,n:ll;
        s:shortstring;
begin
        readln(s);
        n:=0;
        val(s[1],a);val(s[2],b);val(s[4],c);val(s[5],d);
        while (a<>d)or(b<>c)do
        begin
                inc(n);
                if d<9 then inc(d)
                else begin
                        d:=0;
                        if c<5 then inc(c)
                        else begin
                                c:=0;
                                if (b<9)and(a<2) then inc(b)
                                else if (b<3)and(a<3) then inc(b)
                                else begin
                                        b:=0;
                                        if a<2 then inc(a)
                                        else begin
                                                a:=0;
                                             end;
                                     end;
                             end;
                     end;
        end;
        writeln(n);
end.

var
  s : string;
  a,b,c,d,ans : longint;
  function ok(a,b : longint) : boolean;
  var
    a1,b1,c1,d1 : longint;
    begin
      ok:=false;
      a1:=a div 10;
      b1:=a mod 10;
      c1:=b div 10;
      d1:=b mod 10;
      if (b1=c1) and (a1=d1) then ok:=true;
    end;
begin
  readln(s);
  val(s[1],a);
  val(s[2],b);
  val(s[4],c);
  val(s[5],d);
  a:=a*10+b;
  c:=c*10+d;
  while not ok(a,c) do
    begin
      inc(ans);
      if c<59
        then inc(c)
        else begin
               dec(c,59);
               if a<23 then inc(a)
                       else dec(a,23);
             end;
    end;
  writeln(ans);
end.

const   fi='';
var
        t:string; res:int32;

function palin(s:string):boolean;
begin
        exit( (s[1]=s[5]) and (s[2]=s[4]) );
end;
procedure incr(var s:string);
var sh,sm:string; h,m:int32;
begin
        inc(res);
        h:= (ord(s[1])-ord('0'))*10+ord(s[2])-ord('0');
        m:= (ord(s[4])-ord('0'))*10+ord(s[5])-ord('0');
        inc(m);
        if m=60 then
        begin
                m:= 0; inc(h);
        end;
        if h=24 then h:= 0;
        str(h,sh);
        str(m,sm);
        if length(sh)=1 then sh:= '0'+sh;
        if length(sm)=1 then sm:= '0'+sm;
        s:= sh+':'+sm;
end;
procedure print;
begin
        res:= 0;
        while not palin(t) do incr(t);
        write(res);
end;

begin
        assign(input,fi); reset(input);
        read(t);
        print;
        close(input);
end.

var s,x:string;
       k,f,i,p,g,a,b:longint;
begin
readln(s);
k:=0;
f:=0;
while f=0 do begin
p:=0;
for i:=1 to 2 do if (s[i]<>s[5-i+1])then p:=1;
if p=0 then begin
writeln(k);
f:=1;
exit;
end;
val(copy(s,1,2),a,g);
val(copy(s,4,2),b,g);
b:=b+1;
if b>=60 then begin
b:=0;
a:=a+1;
end;
if A>=24 then a:=0;
s:='';
if a<10 then begin
str(a,x);
s:='0'+x+':';
end
else begin
str(a,x);
s:=x+':';
end;
if b<10 then begin
str(b,x);
s:=s+'0'+x;
end
else begin
str(b,x);
s:=s+x;
end;
k:=k+1;
end;
end.

var st:string;A:array[0..25] of string;kt:array[0..25] of boolean;
procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;
function        dao(st:string):string;
var s:string;i:longint;
begin
        s:='';
        for i:=length(st) downto 1 do
                s:=s+st[i];
        exit(s);
end;
procedure       nhap;
var s:string;i:longint;
begin
        readln(st);
        for i:=0 to 5 do kt[i]:=true;
        for i:=10 to 15 do kt[i]:=true;
        for i:=20 to 24 do kt[i]:=true;
        for i:=0 to 23 do
                begin
                str(i,s);
                if length(s)<=1 then s:='0'+s;
                S:=s+':'+dao(s);
                A[i]:=s;
                end;
                A[24]:=A[0];
end;
procedure       xuli;
var s,ss:string;n,code,i,x,y,dem:longint;
begin

        s:=copy(st,1,2);dem:=0;
        val(s,n,code);
        ss:=copy(A[n],pos(':',st)+1,2);
        s:=copy(st,pos(':',st)+1,2);
        val(s,x,code);
        val(ss,y,code);
        if (kt[n]=true) and(x<=y) then
                begin
                writeln(y-x);
                halt;
                end
        else
        begin
                inc(n);
                inc(dem);
                while not kt[n] do
                        begin
                        inc(n);
                        inc(dem);
                        end;

        ss:=copy(A[n],pos(':',st)+1,2);
        val(ss,y,code);
        writeln(y+60*dem-x);
end;

end;
begin
        //mo;
        nhap;
        xuli;
        //dong;
end.

var s,s1,s2:string;
i,j,h,m,code,k,q:longint;
begin
read(s);
s1:=s[1]+s[2];
val(s1,h,code);
s1:=s[4]+s[5];
val(s1,m,code);
for i:=h to 23 do
for j:=0 to 59 do begin
str(i,s2);
if i<10 then s1:='0'+s2+':' else s1:=s2+':';
str(j,s2);
if j<10 then s1:=s1+'0'+s2 else s1:=s1+s2;
s2:='';
for q:=length(s1) downto 1 do
s2:=s2+s1[q];
if s1=s then k:=0;
if (s2=s1)and(i>h) then begin writeln(k);exit;end;
if (s2=s1)and(i=h)and(j>=m) then begin writeln(k);exit;end;
inc(k);
end;
writeln(k);
End.

const fi='816A.inp';
        fo='816A.out';
var s,x:string;
        h,m,i,kq,c,k:longint;
function kt(h,m:longint):boolean;
        begin
                if (m mod 10)*10+m div 10=h then exit(true);
                exit(false);
        end;
begin

        readln(s);
        x:=s[1]+s[2];val(x,h,c);
        x:=s[4]+s[5];val(x,m,c);
        for i:=1 to 1000000 do
                if kt(h,m) then break
                        else
                                begin
                                        inc(m);
                                        if m=60 then m:=0;
                                        if m=0 then inc(h);
                                        if h=24 then h:=0;
                   end;
        writeln(i-1);
end.

var s,z:string;
min,i,k,y,x,j:longint;
a:array [00..1000005] of longint;
begin
min:=maxlongint;
        readln(s);
        for i:=0 to 1 do
                for j:=0 to 5 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+i)*60 + i*10+2;
                end;
        for i:=0 to 1 do
                for j:=0 to 5 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i+1440;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+i)*60 + i*10+2+1440;
                end;
        for i:=1 to 2 do
                z:=z+s[i];
        val(z,x);
        z:='';
        for i:=4 to 5 do
                z:=z+s[i];
        val(z,y);
        for i:=1 to k*2 do
                begin
                if ((a[i]-(x*60+y))<min)and(a[i]-(x*60+y)>=0) then min:=(a[i]-(x*60+y));
                end;
        write(min);
end.

var h,p,i,code,n,res,j,k:longint;
    cc,pp,s,ss,s1,ss1:string;

begin
read(s);
for i:=1 to length(s) do
    begin
        if s[i]=':' then break else cc:=cc+s[i];
    end;
val(cc,h,code);
for i:=i+1 to length(s) do
    begin
        pp:=pp+s[i];
    end;
val(pp,p,code);
for i:=h to 23 do
    For j:=0 to 59 do
        begin
            if (i=h) and (j<p) then continue;
            str(i,s);
            if i<10 then s:='0'+s;
            str(j,s1);
            if  (j<10) then s1:='0'+s1;
            ss:=s+s1;
            ss1:='';
            for k:=length(ss) downto 1 do
                ss1:=ss1+ss[k];
            if ss=ss1 then
                begin
                    res:=res+(i-h-1)*60+(60+j-p);
                    writeln(res);
                    halt;
                end;
        end;
res:=res+(23-h)*60+60-p;
writeln(res);
end.

var     f1,f2:text;
        st,sh,sm,dx:string;
        x,y,er,m,z: integer;
begin
        readln(st);

        m:=0;
        sh:= copy(st,1,2); sm:= copy(st,4,2); dx:= sh[2]+sh[1];
        val(dx,x,er); val(sm,y,er);    val(sh,z,er);
        while x<>y do
        begin
                inc(m);
                inc(y); if y=60 then begin inc(z); y:=0; end;
                if z=24 then z:=0;
                x:=((z mod 10)*10)+(z div 10);
        end;

        writeln(m);
end.

var s,tg:string;
    t,tg1,k,ans:longint;
function pali(n:string):boolean;
var i:longint;
    m:string;
begin
        for i:=length(n) downto 1 do if n[i]<>n[length(n)-i+1]  then exit(false);
        exit(true);
end;
begin
        read(s);
        while pali(s)=false do
        begin
                if (s[4]='5') and (s[5]='9') then
                begin
                        delete(s,4,2);
                        s:=s+'00';
                        if (s[1]='2') and (s[2]='3') then begin delete(s,1,2); s:='00'+s; end else
                        begin
                                val(s[2],k,t);
                                inc(k);
                                if k=10 then
                                begin
                                        val(s[1],tg1,t);
                                        inc(tg1);
                                        str(tg1,tg);
                                        delete(s,1,2);
                                        s:=tg+'0'+s;
                                end else
                                begin
                                        str(k,tg);
                                        delete(s,2,1);
                                        insert(tg,s,2);
                                end;
                        end;
                end
                else
                begin
                        tg:=s[4]+s[5];
                        delete(s,4,2);
                        val(tg,k,t);
                        inc(k);
                        str(k,tg);
                        if k<10 then tg:='0'+tg;
                        s:=s+tg;

                end;

                inc(ans);
        end;
        writeln(ans);
end.

const fi='';
      fo='';
      maxn=1000000;

var   s,smin:string;
      b:array[1..maxn] of string;
      dem,min:longint;
procedure nhapdl;
begin
      readln(s);
      min:=0;
end;

procedure xuly;
var   i,j,c,t1,t2:longint;
      a,m:string;
begin

      a:='';
      for i:=0 to 23 do
           begin
                   j:=i;
                   str(j,a);
                   if (length(a)=1) and (a[1] <= '5') then
                                begin
                                        inc(dem);
                                        a:='0'+a+a[1]+'0';
                                        b[dem]:=a;
                                end
                   else if (a[2] <= '5') and (length(a)=2) then
                        begin
                                inc(dem);
                                a:=a + a[2] + a[1];
                                b[dem]:=a;
                        end;
                   a:='';
           end;
      delete(s,3,1);
      smin:='2400';
      for i:=1 to dem do
           if b[i] >= s then
                begin
                        smin:=b[i];
                        break;
                end;
      if s[1]='0' then delete(s,1,1);
      if smin[1]='0' then delete(smin,1,1);
      val(s,t1,c);
      val(smin,t2,c);
      if (t2 mod 100 - t1 mod 100) >= 0 then
                min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60
      else      begin
                        t2:=t2 - 40;
                        min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60;
                end;
      write(min);

end;

BEGIN
      assign(input, fi);reset(input);
      assign(output, fo);rewrite(output);
      nhapdl;
      xuly;
      close(input);close(output);
END.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if ((m>l) or ((m=l) and (c>j))) and (m2<>60) and (m2<>70) and (m2<>80) and (m2<>90) and (m2<>61) and (m2<>71) and (m2<>81) and (m2<>91)
then begin write(m2-m3);exit;end;

k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;

if k=6 then begin h:=h+60;k:=k+1;end;
if k=7 then begin h:=h+60;k:=k+1;end;
if k=8 then begin h:=h+60;k:=k+1;end;
if k=9 then begin h:=h+60;k:=k+1;end;
if k=16 then begin h:=h+60;k:=k+1;end;
if k=17 then begin h:=h+60;k:=k+1;end;
if k=18 then begin h:=h+60;k:=k+1;end;
if k=19 then begin h:=h+60;k:=k+1;end;

if k=0 then begin write(h);exit;end;

h:=h+(k mod 10)*10+(k div 10);
write(h);
end.

const fi='';
      fo='';

var f,g:text;
s:string;
d:longint;

function tang(s:string):string;
var h,m:longint;
sh,sm:string;
begin
	sh:=s[1]+s[2];
	sm:=s[4]+s[5];
	val(sh,h);
	val(sm,m);
	inc(m);
	h:=(h+(m div 60)) mod 24;
	m:=m mod 60;
      str(h,sh); if length(sh)=1 then sh:='0'+sh;
      str(m,sm); if length(sm)=1 then sm:='0'+sm;
      exit(sh+':'+sm);
end;

function palindrom(s:string):boolean;
begin
	if (s[1]=s[5]) and (s[2]=s[4]) then exit(true);
	exit(false);
end;

begin
	assign(f,fi);reset(f);
	assign(g,fo);rewrite(g);
	readln(f,s);
	d:=0;
	while not palindrom(s) do
		begin
			s:=tang(s);
			inc(d);
		end;
	writeln(g,d);
	close(f);
	close(g);
end.

var st ,st2,st3,st4,s,s1,s2:string;
n,k,m,h,i:longint;
begin
  readln(st);
  n:=length(st);
  for i:=n downto 1 do
    st2:=st2+st[i];
  if st=st2 then begin
                   writeln(0);
                   halt;
                 end;
  s:=copy(st,1,2);
  val(s,h);
  s:=copy(st,4,2);
  val(s,m);
  if (h=23) and (m=59) then begin
                              writeln(1);
                              halt;
                            end;

  while true do
    begin
      st3:='';
      st4:='';
      k:=k+1;
      m:=m+1;
      if m=60 then begin
                     if h=23 then h:=0
                             else h:=h+1;
                     m:=0;
                   end;
      if (h=23) and (m=59) then begin
                                  k:=k+1;
                                  writeln(k);
                                  halt;
                                end;
      str(h,s1);
      str(m,s2);
      if m<10 then s2:='0'+s2;
      if h<10 then s1:='0'+s1;
      st3:=s1+s2;
      n:=length(st3);
      for i:=n downto 1 do
        st4:=st4+st3[i];
      if st4=st3 then begin
                        writeln(k);
                        halt;
                      end;
    end;
end.

var h,m:string[2];
    c:char;
    s,e,r:string;
    i,a,b,ans:longint;
    x:boolean;
begin
	readln(h,c,m);
	val(h,a);
	val(m,b);
	ans:=0;
	x:=false;
	repeat
		str(a,e);
		if a<10 then e:='0'+e;
		str(b,r);
		if b<10 then r:='0'+r;
		s:=e+r;
		x:=true;
		for i:=1 to 2 do
		if s[i]<>s[5-i] then x:=false;
		if x=false then inc(ans);
		inc(b);
		if b=60 then
		begin
			b:=0;
			inc(a);
			if a=24 then a:=0;
		end;
	until x;
	writeln(ans);
	readln;
end.

uses math;
var n,m,i,j,ans:longint;
    a:array[0..100100]of longint;
    s:string;
    flag:boolean;
    c1,c2,c3,c4,c5:char;

function check:boolean;
begin if (c1+c2)=(c5+c4) then exit(true);exit(false);end;

procedure nx;
begin
  if c5 in ['0'..'8'] then c5:=chr(ord(c5)+1) else begin
    c5:='0';c4:=chr(ord(c4)+1);
  end;
  if c4='6' then begin
    c4:='0';
    if c2 in ['0'..'8'] then c2:=chr(ord(c2)+1) else begin
      C2:='0';c1:=chr(ord(c1)+1);
    end;
  end;
  if (c1='2')and(c2='4') then begin
    c1:='0';c2:='0';
  end;
end;

begin
readln(c1,c2,c3,c4,c5);
ans:=0;
while not check do begin inc(ans);nx;end;
writeln(ans);
end.

uses sysutils;
var s:ansistring;
a,b,i:longint;
function test(a,b:longint):boolean;
begin
 test:=(a mod 10 = b div 10)and(a div 10 = b mod 10);
end;
begin
 read(s);
 a:=strtoint(s[1]+s[2]);
 b:=strtoint(s[4]+s[5]);
 for i:=1 to 60*24 do begin
        if test(a,b) then begin
                write(i-1);
                exit;
        end;
        inc(b);
        a:=(a+(b div 60))mod 24;
        b:=b mod 60;
 end;
end.

var st,s1,s2:string;
    so1,so2,i,j,code,d:longint;
function kt(s:string):boolean;
var i:longint;
begin
     for i:=1 to length(s) div 2 do
        if s[i]<>s[length(s)+1-i] then exit(false);
     exit(true);
end;
begin
     read(st);
     s1:=st[1]+st[2];
     s2:=st[4]+st[5];
     val(s1,so1,code);
     val(s2,so2,code);
     while so1<24 do begin
           while so2<60 do begin
                 str(so1,s1);
                 str(so2,s2);
                 if length(s1)=1 then s1:='0'+s1;
                 if s1='24' then s1:='00';
                 if length(s2)=1 then s2:='0'+s2;
                 st:=s1+':'+s2;
                 inc(d);
                 if kt(st) then begin
                                     write(d-1);
                                     halt;
                                end;
                 inc(so2);
           end;
           so2:=0;
           if so1=23 then so1:=0 else inc(so1);
        end;
end.

var
 s : string;
 h1,h2,m1,m2,h,m,kol : longint;
 _ : integer;

  function prov(a,b : longint):boolean;
  var s1,s2 : string;
   begin
    str(a,s1);
    if length(s1)=1 then s1:='0'+s1;
    str(b,s2);
    if length(s2)=1 then s2:='0'+s2;
    if (s1[1]=s2[2]) and (s2[1]=s1[2]) then prov:=true else prov:=false;
   end;

begin
 readln(s);
 val(s[1],h1,_);
 val(s[2],h2,_);
 val(s[4],m1,_);
 val(s[5],m2,_);
 h:=h1*10+h2;
 m:=m1*10+m2;
 kol:=0;
 if prov(h,m) then writeln(0) else
 while true do
  begin
   inc(kol);
   inc(m);
   if m=60 then begin m:=0; inc(h); end;
   if h=24 then h:=0;
   if prov(h,m) then begin writeln(kol); halt; end;
  end;
end.

const fi='';
    fo='';
var f:text;
    s:string;
function check(s:string):boolean;
var i:0..3;
begin
    for i:=1 to 2 do
    if (s[i]<>s[5-i+1]) then exit(false);
    exit(true);
end;
function plus(s:string):string;
var  x:integer;
    s1:string;
begin
    val(s,x);
    inc(x);
    str(x,s1);
    if (length(s1)=1) then s1:='0'+s1;
    exit(s1);
end;
procedure process;
var  d:integer;
    x,y:string;
begin
    d:=0;
    while not(check(s)) do
    begin
        inc(d);
        x:=s[1]+s[2];y:=s[4]+s[5];
        if (y='59') then
        begin
            y:='00';
            if (x='23') then x:='00' else x:=plus(x);
        end
        else    y:=plus(y);
        s:=x+':'+y;
    end;
    assign(f,fo);rewrite(F);
    writeln(f,d);
    close(F);
end;

begin
    assign(f,fi);reset(f);
    read(f,s);
    close(F);
    process;
end.

var
  ch1,ch2,ch3,ch4:char;
  t,t1,t2:longint;
begin
  read(ch1,ch2,ch3,ch3,ch4);
  t1:=(ord(ch1)-ord('0'))*10+ord(ch2)-ord('0');
  t2:=(ord(ch3)-ord('0'))*10+ord(ch4)-ord('0');
  t:=0;
  while true do
    begin
      inc(t);
      if (t1 div 10=t2 mod 10)and(t1 mod 10=t2 div 10)then
        begin
          writeln(t-1);
          halt;
        end;
      inc(t2);
      if t2>=60 then
        begin
          t2:=t2-60;
          inc(t1);
        end;
      if t1=24 then
        begin
          writeln(t);
          halt;
        end;
    end;
end.

program zzz;
var
  kol:integer;
  s:string;
  h,m:array[1..2]of integer;
begin
readln(s);
val(s[1],h[1]);
val(s[2],h[2]);
val(s[4],m[1]);
val(s[5],m[2]);
kol:=0;
while (h[1]<>m[2]) or (h[2]<>m[1]) do
begin
  inc(kol);
  inc(m[2]);
  if m[2]=10 then begin
                    m[2]:=0;
                    inc(m[1]);
                  end;
  if m[1]=6 then begin
                    m[1]:=0;
                    inc(h[2]);
                  end;
    if (h[2]=10)and(h[1]<>2)   then begin
                    h[2]:=0;
                    inc(h[1]);
                  end;
    if (h[2]=4) and (h[1]=2) then begin
                    h[2]:=0;
                    h[1]:=0;
                  end;
end;
writeln(kol);
end.

var s:string; a,b,c,t1,t2:longint;
begin
  readln(s);
  val(s[1],t1); val(s[2],t2);
  a:= t1 + t2*10;
  val(s[4],t1); val(s[5],t2);
  b:= t1*10 + t2 ;
  c:=0;
  while a<>b do begin
	inc(b);inc(c);
	if b=60 then begin inc(a,10); b:=0;
	  if a mod 100 < 2 then a:=(a mod 100)+1;
	end;
	if a = 42 then a:=0;
  end;
  writeln(c);
end.

const           fi='';
                n=5;
                fo='';
var             s:shortstring;
                f:text;
function        palin(s:shortstring):boolean;
begin
                if (s[1]=s[5]) and (s[2]=s[4]) then exit(true);
                exit(false);
end;
function        push(s:shortstring):shortstring;
var             t1,t2:integer;
                u,l,h:shortstring;
                up:boolean;
begin
                t1:=(ord(s[1])-ord('0'))*10+ord(s[2])-ord('0');
                t2:=(ord(s[4])-ord('0'))*10+ord(s[5])-ord('0');
                inc(t2);
                if t1<=9 then u:='0' else u:='';
                up:=false;
                if t2>=60 then
                        begin
                                up:=true;
                                l:='00';
                                inc(t1);
                        end;
                if t1>=10 then u:='';
                if t1>=24 then u:='00:' else
                        begin
                                str(t1,h);
                                u:=u+h+':';
                        end;
                if up then u:=u+l else
                        if t2<=9 then
                        begin
                                str(t2,l);
                                u:=u+'0'+l;
                        end else
                                begin
                                        str(t2,l);
                                        u:=u+l;
                                end;
                exit(u);
end;
procedure       solve;
var             res:integer;
begin
                res:=0;
                while not palin(s) do
                        begin
                                inc(res);
                                s:=push(s);
                        end;
                write(f,res);
end;
procedure       enter;
var             f:text;
begin
                assign(f,fi);
                reset(f);
                readln(f,s);
                solve;
                close(f);
end;
begin
                assign(f,fo);
                rewrite(f);
                enter;
                close(f);
end.

var
  s:string;
  h,m,i:longint;

begin
  readln(s);
  val(copy(s,1,2),h,i);
  val(copy(s,4,2),m,i);
  for i:=0 to 1440 do
    begin
      if ((h div 10)=(m mod 10))and
         ((h mod 10)=(m div 10))
        then break;
      inc(m);
      if m=60 then
        begin
          m:=0;
          inc(h)
        end;
      if h=24 then h:=0
    end;
  writeln(i)
end.

var h,m,q,sum,i,j,n:longint;
    s:string;
function qwe(x,y:longint):boolean;
begin
 if (x div 10=y mod 10)and(y div 10=x mod 10) then
 qwe:=true else
 qwe:=false;
end;
begin
 readln(s);
 val(s[1]+s[2],h,q);
 val(s[4]+s[5],m,q);
 sum:=0;
 for  i:=h to 23 do
  for  j:=0 to 59 do
   if (qwe(i,j))and((not(i=h))or(not(j<m)))then
   begin
    writeln(sum);
    exit;
   end else
   if not((i=h)and(j<m)) then
   inc(sum);
 writeln(sum);
end.

uses math;
var s: string[5];
    i, j, h, m, log, res: LongInt;

function palindromes(h, m: LongInt): Boolean;
begin
    if ((h mod 10 = m div 10) and (h div 10 = m mod 10)) then exit(true);
    exit(false);
end;

function cal(i, j, h, m: LongInt): LongInt;
begin
    if ((i = h) and (j = m)) then exit(0);
    if (i = h) then
     begin
        if (j > m) then exit(j - m);
        if (j < m) then exit(60 * 24 + j);
     end;
    if (i > h) then exit((i - h - 1) * 60 + ((60 - m) + j));
    if (i < h) then exit(60 * (24 - h - 1 + i) + (60 - m) + j);
end;

begin
    read(s);
    val(copy(s, 1, 2), h, log);
    val(copy(s, 4, 2), m, log);

    res := maxint;
    for i := 0 to 23 do
    for j := 0 to 59 do
     begin
        if (palindromes(i, j)) then res := min(res, cal(i, j, h, m));
     end;

    write(res);
end.

program yan;
  var s:string; i,j,x,y,a,b,n,m:integer;
begin
  readln(s);
  val(s[1]+s[2],x,y); val(s[4]+s[5],a,y);
  while x<>(a mod 10)*10+(a div 10) do
    begin
      inc(a); inc(b);
      if a>59 then begin a:=0; inc(x); end;
      if x>23 then x:=0;
    end;
  write(b);
end.

Program _816_A;
const   finput='816_A.inp';
        foutput='816_A.out';
var     h,m,cnt:longint;
        s:string;
Procedure Nhap;
var code:longint;
begin
    //assign(input,finput);reset(input);
    //assign(output,foutput);rewrite(output);
    readln(s);
    Val(copy(s,1,2),h,code);
    Val(copy(s,4,2),m,code);
end;

Function P(a,b:longint):boolean;
var h1,h2,m1,m2:longint;
begin
    h1:=h div 10;
    h2:=h mod 10;
    m1:=m div 10;
    m2:=m mod 10;
    if (h1=m2)and(h2=m1) then exit(true);
    exit(false);
end;

Procedure Xuli;
begin
    cnt:=0;
    while P(h,m)=false do
        begin
        inc(cnt);
        inc(m);
        if m=60 then
            begin
            inc(h);
            if h=24 then h:=0;
            m:=0;
            end;
        end;
end;

Procedure xuat;
begin
    write(cnt);
end;

begin
    Nhap;
    Xuli;
    xuat;
end.

uses sysutils;
var check1, check2, check3, check4:ansistring;
	s:string;
	hour,minute,i:longint;
begin
	//assign(input,'816A.inp'); reset(input);
	//assign(output,'816A.out'); rewrite(output);
	readln(s);
	hour:=strtoint(copy(s,1,2));
	minute:=strtoint(copy(s,4,2));
	for i:=0 to 3000 do
	begin
		check1:=inttostr(((hour mod 100)-( hour mod 10)) div 10);
		check2:=inttostr(hour mod 10);
		check3:=inttostr(((minute mod 100)- (minute mod 10)) div 10);
		check4:=inttostr(minute mod 10);
		if (check1=check4) and (check2=check3) then
		begin
			write(i);
			break;
		end;
		if minute<59 then inc(minute)
		else
		begin
			minute:=0;
			if hour<23 then inc(hour) else hour:=0;
		end;
	end;
	//close(input); close(output);
end.

var
    h,m,ans:longint;
    h1,h2,m1,m2,ch:char;

function check(h,m:longint):boolean;
begin
    exit((h div 10=m mod 10)and(h mod 10=m div 10));
end;

procedure iinc;
begin
    inc(ans);
    m:=m+1;
    if m=60 then
    begin m:=0;inc(h);if h=24 then h:=0;end;
end;

begin
    read(h1,h2,ch,m1,m2);
    h:=(ord(h1)-48)*10+ord(h2)-48;
    m:=(ord(m1)-48)*10+ord(m2)-48;
    while not check(h,m) do iinc;
    writeln(ans);
end.

var s,hs,ms:string;
h,m,k,err:integer;
begin
read(s);
hs:=copy(s,1,2);
ms:=copy(s,4,2);
val(hs, h,err);
val(ms,m,err);

while (h mod 10<>m div 10)or(h div 10<> m mod 10) do begin
k+=1;
m+=1;
if m=60 then begin m:=0; h+=1 end;
if h=24 then h:=0;

end;
writeln(k);
end.

const fi='';
      fo='';
var h,m,r:longint;
procedure enter;
var s,t:string;
    code:longint;
begin
        assign(input,fi);
        reset(input);
        readln(s);
        t:=copy(s,1,2);
        val(t,h,code);
        t:=copy(s,4,2);
        val(t,m,code);
        close(input);
end;
function check:boolean;
var th,tm:string;
begin
        str(h,th);
        str(m,tm);
        if length(th)=1 then th:='0'+th;
        if length(tm)=1 then tm:='0'+tm;
        exit((th[1]=tm[2]) and (th[2]=tm[1]));
end;
procedure solve;
begin
        r:=0;
        while not check do
                begin
                        inc(m);
                        if m=60 then
                                begin
                                        inc(h);
                                        m:=0;
                                end;
                        if h=24 then h:=0;
                        inc(r);
                end;
end;
procedure print;
begin
        assign(output,fo);
        rewrite(output);
        write(r);
        close(output);
end;
begin
        enter;
        solve;
        print;
end.

var hh, mm, i, p : integer;
  s : string;

begin
  i := 0;
  readln(s);
  hh := (ord(s[1])-48)*10 + ord(s[2])-48;
  mm := (ord(s[4])-48)*10 + ord(s[5])-48;
  p := (hh mod 10)*10 + (hh div 10);
  while p <> mm do begin
    hh := (hh + (succ(mm) div 60)) mod 24;
    mm :=  succ(mm) mod 60;
    i := succ(i);
    p := (hh mod 10)*10 + (hh div 10);
  end;
  write(i);
end.

Uses math;
Var fi, fo: text;
    s, sh, sm: string;
    h, m, i, j, res: Longint;

Begin
	assign(fi,''); reset(fi);
	assign(fo,''); rewrite(fo);
	readln(fi, s);
	h:= (ord(s[1]) - 48)*10 + ord(s[2]) - 48;
	m:= (ord(s[4]) - 48)*10 + ord(s[5]) - 48;
	for i:=h to 24 do
	begin
		if i=24 then sh:= '00'
		else
			if (i div 10)=0 then sh:= '0' + chr(i+48)
			else str(i, sh);
		if i=h then
		begin
			for j:=m to 59 do
			begin
				if j=60 then sm:= '00'
				else
					if (j div 10)=0 then sm:= '0' + chr(j+48)
					else str(j, sm);
				if (sh[1]+sh[2])=(sm[2]+sm[1]) then
				begin
					writeln(fo, res);
					close(fi); close(fo);
					exit;
				end;
				inc(res);
			end;
		end
		else
		begin
			for j:=0 to 59 do
			begin
				if j=60 then sm:= '00'
				else
					if (j div 10)=0 then sm:= '0' + chr(j+48)
					else str(j, sm);
				if (sh[1]+sh[2])=(sm[2]+sm[1]) then
				begin
					writeln(fo, res);
					close(fi); close(fo);
					exit;
				end;
				inc(res);
			end;
		end;
	end;
End.

var s:string;
hours,minutes,code,time:integer;
function pal(hours,minutes:integer):boolean;
        begin
        if hours = (minutes mod 10)*10 + (minutes div 10)  then pal:=true else pal:=false;
        end;
begin
readln(s);
val( copy(s,1,2), hours, code );
val( copy(s,4,2), minutes, code );
while not pal(hours,minutes) do
        begin
        if minutes=59 then
                begin
                if hours=23 then hours:=0
                        else inc(hours);
                minutes:=0;
                end
                else inc(minutes);
        inc(time);
        end;
writeln(time);
end.

var s,a,b:string;
    x,y,code,i,j,t,t1:longint;

function dao(a:longint):longint;
        begin
        a:=a+(a mod 10) *100;
        a:=a div 10;
        exit(a);
        end;
begin
readln(s);
a:=s[1]+s[2];
b:=s[length(s)-1]+s[length(s)];
val(a,x,code);
val(b,y,code);
t:=dao(x);t1:=0;
while y<>t do
        begin
        inc(y);
        inc(t1);
        IF y=60 then
                begin
                inc(x);
                y:=0;
                end;
        IF x=24 then
                begin
                x:=0;
                y:=0;
                end;
        t:=dao(x);
        end;
write(t1);
end.

const
 fi='';
 fo='';
var
 f:text;
 s:string;
procedure docfile;
var c:char;
begin
        assign(f,fi);
        reset(f);
        readln(f,s);
end;
function ct(x:string;y:integer):string;
var tmp,tmp1,tmp2,tmp3:longint;  s1,s2:string;
begin
     s1:=x[1]+x[2];
     s2:=x[4]+x[5];
     val(s1,tmp);
     val(s2,tmp1);
     tmp2:=(tmp*60+tmp1+y)mod 1440;
     ct:='xx:xx';
     str(tmp2 div 60,s1);
     tmp3:=tmp2 - (tmp2 div 60)*60;
     if(tmp2 div 60 < 9) then
      begin
          ct[1]:='0';
          ct[2]:=chr(tmp2 div 60 +48);
      end else
      begin
          ct[1]:=s1[1];
          ct[2]:=s1[2];
      end;
     if(tmp3 = 0) then
     begin ct[4]:='0';ct[5]:='0'; end
     else if(tmp3 < 9 ) then
     begin
      ct[4]:='0'; ct[5]:=chr(tmp3+ord('0'));
      end else
     begin
        str(tmp3,s2);
        ct[4]:=s2[1];
        ct[5]:=s2[2];

     end;
end;
function pali(x:string):boolean;
begin
    if (x[1] = x[5]) and(x[2] = x[4]) then exit(true);
    exit(False);
end;
procedure xl;
var i:longint; tmp:string;
begin
    if(pali(s)) then
     begin
         writeln(0);
         halt;
     end;
    for i:=1 to 1440 do
     begin
         tmp:=ct(s,i);
         if(pali(tmp)) then
          begin
              writeln(i);
              halt;
          end;
     end;
end;
begin
    docfile;

    xl;

end.

Var
    st:string;
    total:longint;

Procedure Nhap;
Var i:longint;
    begin
    Readln(St);
    End;

Procedure Xuly;
Var hh,mm:longint;
    h,m:string;
    Begin
    h:=st[1]+st[2];
    val(h,hh);
    h:=st[2]+st[1];
    m:=st[4]+st[5];
    val(m,mm);
    While h<>m do
        Begin
        mm:=mm+1;
        inc(total);
        If mm >= 60 then
            Begin
            mm:=mm mod 60;
            inc(hh);
            End;
        hh:=hh mod 24;
        str(mm,m);
        str(hh,h);
        If length(m)=1 then m:='0'+m;
        If length(h)=1 then h:='0'+h;
        h:=h+h[1];
        delete(h,1,1);
        End;
    Write(total);
    End;

Begin
    Nhap;
    Xuly;
End.

const fi='';
      fo='';
var st,h,m:string;
procedure openf;
begin
   assign(input,fi);
   reset(input);
   assign(output,fo);
   rewrite(output);
end;
procedure closef;
begin
   close(input);
   close(output);
end;
procedure solve;
var g,p,kq:longint;
begin
   readln(st);
   h:=st[1]+st[2];
   m:=st[4]+st[5];
   kq:=0;
   repeat
       if(h[1]=m[2]) and (h[2]=m[1]) then
       begin
         write(kq);
         break;
       end;
       inc(kq);
       val(m,p);
       inc(p);
       if p=60 then
       begin
         val(h,g);
         inc(g);
         if  g=24 then h:='00'
         else
         begin
            str(g,h);
            if g<10 then h:='0'+h;
         end;
         m:='00';
         if (h='00') and (m='00') then
         begin
            write(kq);
            exit;
         end;
       end
       else
       begin
         str(p,m);
         if p<10 then m:='0'+m;
       end;
   until false;
end;
BEGIN
   openf;
   if (h='00') and (m='00') then write(0) else
   solve;
   closef;
END.

const
	fi='';
	fo='';

var
	s:string;
	h1,h2,m1,m2,t:longint;

procedure enter;
        var x:char;
                i:longint;
	begin
                s:='     ';
                for i:=1 to 5 do
                begin
		read(x);
                s[i]:=x;
                end;
                readln;
	end;

function check(s:string):boolean;
	var x:longint;
	begin
		x:=(ord(s[4])-48)*10 + ord(s[5])-48;
		if x>=60 then exit(false);
	end;

procedure solve;
	var
		i,nho,c:longint;
                s2,x:string;
	begin
		s2:='';
		h1:=(ord(s[1])-48)*10 + ord(s[2])-48;
		m1:=(ord(s[4])-48)*10 + ord(s[5])-48;
		h2:=h1;
		//
		s2:=s2+s[1];
		s2:=s2+s[2];
                s2:=s2+':';
		s2:=s2+s2[2];
		s2:=s2+s2[1];
		while (s2<s) or (check(s2)=false) do
		begin
			inc(h2);
			str(h2,x);
                        if h2<10 then x:='0'+x;
                        s2[1]:=x[1];
                        s2[2]:=x[2];
			s2[4]:=x[2];
			s2[5]:=x[1];
			if h2=24 then begin s2[4]:='0';s2[5]:='0' end
		end;
		m2:=(ord(s2[5])-48)+(ord(s2[4])-48)*10;
		nho:=0;
		c:=m2-m1;
		if c<0 then
			begin
			c:=c+60;
			nho:=1;
			end;
		c:=60*(h2-h1-nho)+c;
		writeln(c);
	end;

begin
        t:=1;
        assign(input,fi);
        reset(input);
        assign(output,fo);
        rewrite(output);

        while  t>0 do
        begin
	enter;
      	solve;
        dec(t);
        end;
        close(input);
        close(output);
end.

const
	fi='';
	fo='';

var
	s:string;
	h1,h2,m1,m2,t:longint;

procedure enter;
        var x:char;
                i:longint;
	begin
                readln(s);
                while (s[1]=' ') do delete(s,1,1);
	end;

function check(s:string):boolean;
	var x:longint;
	begin
		x:=(ord(s[4])-48)*10 + ord(s[5])-48;
		if x>=60 then exit(false);
	end;

procedure solve;
	var
		i,nho,c:longint;
                s2,x:string;
	begin
		s2:='';
		h1:=(ord(s[1])-48)*10 + ord(s[2])-48;
		m1:=(ord(s[4])-48)*10 + ord(s[5])-48;
		h2:=h1;
		//
		s2:=s2+s[1];
		s2:=s2+s[2];
                s2:=s2+':';
		s2:=s2+s2[2];
		s2:=s2+s2[1];
		while (s2<s) or (check(s2)=false) do
		begin
			inc(h2);
			str(h2,x);
                        if h2<10 then x:='0'+x;
                        s2[1]:=x[1];
                        s2[2]:=x[2];
			s2[4]:=x[2];
			s2[5]:=x[1];
			if h2=24 then begin s2[4]:='0';s2[5]:='0' end
		end;
		m2:=(ord(s2[5])-48)+(ord(s2[4])-48)*10;
		nho:=0;
		c:=m2-m1;
		if c<0 then
			begin
			c:=c+60;
			nho:=1;
			end;
		c:=60*(h2-h1-nho)+c;
		writeln(c);
	end;

begin
        t:=1;
        assign(input,fi);
        reset(input);
        assign(output,fo);
        rewrite(output);

        while  t>0 do
        begin
	enter;
      	solve;
        dec(t);
        end;
        close(input);
        close(output);
end.

var
a,k,n,i,j,min,h,a1,a2:integer;
inp:string;
begin
min:=0;
h:=0;
K:=0;
read(inp);
val(inp[1..2],h,a1);
val(inp[4..5],min,a2);

for i:=1 to 999999 do
 begin

  if (min mod 10 = h div 10) and (h mod 10 = min div 10) then
  break;
  if (min mod 10 <> h div 10) or (h mod 10 <> min div 10) then
  min:=min+1;
  if min>59 then
  begin
 h:=h+1;
  min:=0;
 end;
 if h>23 then
 h:=0;
 end;
min:=h*60+min;
i:=i-1;
 write(i);

end.

var
	h	: array [1..5] of char;
	n	: array [1..4] of integer;
	i	: integer;

function dif(a,b,c,d:integer): integer;
begin
	dif:=60+(b-c)*10+(a-d);
end;

function int(c: char): integer;
begin
	case c of
		'1': int:=1;
		'2': int:=2;
		'3': int:=3;
		'4': int:=4;
		'5': int:=5;
		'6': int:=6;
		'7': int:=7;
		'8': int:=8;
		'9': int:=9;
		'0': int:=0;
	end;
end;

begin
	readln(h);
	for i:=1 to 4 do
	begin
		if (i<3) then
			n[i]:=int(h[i])
		else
			n[i]:=int(h[i+1])
	end;

	if n[2] < 5 then
	begin
		if n[2]<n[3] then
		begin
			inc(n[2]);
			if n[2]=4 then
				if n[1]=2 then
					writeln (dif(0,0,n[3],n[4]))
				else
					writeln (dif(n[1],n[2],n[3],n[4]))
			else
				writeln (dif(n[1],n[2],n[3],n[4]));
		end else
		if n[2]=n[3] then
			if n[1]<n[4] then
			begin
				inc(n[2]);
				if n[2]=4 then
					if n[1]=2 then
						writeln (dif(0,0,n[3],n[4]))
					else
						writeln (dif(n[1],n[2],n[3],n[4]))
				else
					writeln (dif(n[1],n[2],n[3],n[4]));
			end else
				writeln (dif(n[1],n[2],n[3],n[4])-60)
		else
			writeln (dif(n[1],n[2],n[3],n[4])-60)
	end else
	if n[2]>5 then
		writeln ((9-n[2])*60+dif(n[1]+1,0,n[3],n[4]))
	else
		if n[2]=n[3] then
			if n[1]<n[4] then
				writeln (240+dif(n[1]+1,0,n[3],n[4]))
			else
				writeln (dif(n[1],n[2],n[3],n[4])-60)
		else
			writeln (dif(n[1],n[2],n[3],n[4])-60);

end.

var     m,h:longint;

procedure nhap;
var     code:longint;
        s:string;
begin
        readln(s);
        val(copy(s,1,2),h,code);
        val(copy(s,4,2),m,code);
end;

procedure xuli;
var     k:longint;
        t:longint;
begin
        if h<23 then
            begin
                if ((h>=10) and (h<=15) or (h>=20)) or ((h>=0) and (h<=4)) then
                    begin
                        k:=(h mod 10)*10+(h div 10);
                        if m<=k then t:=k-m
                        else
                            begin
                                if h=15 then
                                    begin
                                        t:=60-m;
                                        t:=t+60*4;
                                        t:=t+2;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        inc(h);
                                        k:=(h mod 10)*10+(h div 10);
                                        t:=t+k;
                                    end;
                            end;
                    end
                else
                    begin
                        if h<10 then
                            begin
                                if h=5 then
                                    begin
                                        k:=(h mod 10)*10+(h div 10);
                                        if m<=k then t:=k-m
                                        else
                                            begin
                                                t:=60-m;
                                                t:=t+4*60;
                                                t:=t+1;
                                            end;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        t:=t+60*(10-h-1);
                                        t:=t+1;
                                    end;
                            end
                        else
                            begin
                                 t:=60-m;
                                 t:=t+60*(20-h-1);
                                 t:=t+2;
                            end;
                    end;

            end
        else
            begin
                k:=(h mod 10)*10+(h div 10);
                if m<=k then t:=k-m
                else t:=60-m;
            end;
        writeln(t);
end;

begin
        ///assign(input,'816_a.inp');reset(input);
        //assign(output,'816_a.out');rewrite(output);
                nhap;
                xuli;
end.

var
  s: string;
  i: integer;

function iny(s: string): string;
var
  s1, s2: string;
  m, n: integer;
begin
  s1 := s[1] + s[2];
  s2 := s[4] + s[5];
  m := strtoint(s1);
  n := strtoint(s2);
  if(n = 59) then begin if(m + 1 = 24) then m := -1;if(length('' + (m + 1)) = 2) then begin iny := '' + (m + 1) + ':' + '00';n := 0; end else begin iny := '0' + (m + 1) + ':' + '00';n := 0; end end else
  begin
    n := n + 1;
    if(length('' + m) = 2)
      then
      s1 := '' + m
    else
      s1 := '0' + m;

    if(length('' + n) = 2) then
      iny := s1 + ':' + n
    else
      iny := s1 + ':' + '0' + n;

  end;
end;

begin
  readln(s);i := 0;
  while(true) do
  begin
    if(s = reverseString(s)) then begin writeln(i);exit; end else s := iny(s);
    inc(i);
  end;
end.

var a,x,b,c,d:longint;q,aa,cc,bb,dd:char;z:array['0'..'9']of longint;
begin
z['0']:=0;
for q:='1' to '9' do
z[q]:=1+z[pred(q)];
read(aa,bb,q,cc,dd);
a:=z[aa];c:=z[cc];b:=z[bb];d:=z[dd];x:=0;
while (A<>d)or(b<>c) do
begin
 inc(d);
 if d=10 then begin
  d:=0;inc(c);
  if c=6 then begin
   c:=0;inc(b);
   if 10*a+b=24 then begin a:=0;b:=0;end else if b=10
   then begin b:=0;inc(a);
  end;
 end;
end;
inc(x);
end;
write(x);
end.

   const nn=6000; nnn=2000;eps=0.000000001;  besk1=200000008;
   label 1,2;
    type   { real=double;}  {string=ansistring;}

    mas=array [0..nn] of longint;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of longint;mass1=^mass;
    var pp,p4,kk,q,p3,hmin,hmax,p1,p2,l,r,pos,t,kolx,kolo,ot,nm,n,s1,s2,m,s,imax,smin,cen,dl,t2,p,prost,besk:int64;
    i1,j1,k,step, t1,ii,i,tt,j:longint;
     rr,xx,yy,time,aa,bb,cc:extended;
     sss:array[-10..10000] of char;
     sssnew:array[-10..1000] of char;
     ll,d,c,x,y,a,b:array[-100000..2000000] of int64;
     mask,dda,ddb:array[-10..120,-10..120] of int64;
     ss1,ss2:string;
     poten,potok,diam:array[-100..1000000] of extended;
     pole:array[-1..200,-1..200] of char;
    ss:string;ch:char;
    maxpr:array[0..nn] of string;
    st2:array[0..nnn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     xx1,yy1:array[-1..nn] of double;
     yot:double;
       flag,flag1:boolean;
       matr:array[-10..200,-10..200] of extended;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;

    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function inttotime(t:longint):string;
var t1,t2,p1,p2,p3,p4,i,j:longint; s:string;
begin
  t:=t mod (60*24);
  s:='';
  t1:=t div 60;
  t2:=t mod 60;
  p1:=t1 div 10;
  p2:=t1 mod 10;
  p3:=t2 div 10;
  p4:=t2 mod 10;

  s:=s+chr(p1+48);
  s:=s+chr(p2+48);
  s:=s+':' ;
  s:=s+chr(p3+48);
  s:=s+chr(p4+48);

  inttotime:=s;
end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
  read(ss);
  for i:=0 to 24*60 do if inttotime(i)=ss then p:=i;

 { writeln(p);
 } pp:=p;

  for i:=pp to pp+2000 do
    begin
       ss:=inttotime(i);
     {  writeln(i,' ',ss);
     }  if (ss[1]=ss[5])and(ss[2]=ss[4]) then
       begin  t:=i; goto 2; end;

    end;
 2:
    writeln(t-p);

   1:          close(output);
end.

var
f1,f2:text;
h,m,q,count:longint;
s:string;
begin
read(s);
val(s[1]+s[2],h,q);
val(s[4]+s[5],m,q);
count:=0;
while (h mod 10<>m div 10) or (h div 10<>m mod 10) do
 begin
  inc(m);
  if m=60 then
   begin
    h:=h+1;
    m:=0;
   end;
  if h=24 then h:=0;
  inc(count);
 end;
write(count);
end.

var
  i,j,n,h,m,l,r,k,x:longint;
  flag,err:integer;
  p,p1:array [1..10000] of longint;
    c:char;
    s,s1,s2:string;
begin
  read(s);
  s1:=s[1]+s[2];
  s2:=s[4]+s[5];

  val(s1,h,err);
  val(s2,m,err);
flag:=0;
i:=0;
while (flag=0) do begin
    str(h,s1);
    if (h<10) then s1:='0'+s1;
    str(m,s2);
    if (m<10) then s2:='0'+s2;
    s:=s2[2]+s2[1];
    if (s1=s) then
        flag:=1
    else begin
        i:=i+1;
        m:=m+1;
        if (m=60) then begin
            m:=0;
            h:=h+1;
        end;
        if (h=24) then h:=0;
    end;
end;
writeln(i);
end.

var h,p,i,code,n,res,j,k:longint;
    cc,pp,s,ss,s1,ss1:string;

begin
read(s);
for i:=1 to length(s) do
    begin
        if s[i]=':' then break else cc:=cc+s[i];
    end;
val(cc,h,code);
for i:=i+1 to length(s) do
    begin
        pp:=pp+s[i];
    end;
val(pp,p,code);
for i:=h to 23 do
    For j:=p to 59 do
        begin
            str(i,s);
            if i<10 then s:='0'+s;
            str(j,s1);
            if  (j<10) then s1:='0'+s1;
            ss:=s+s1;
            ss1:='';
            for k:=length(ss) downto 1 do
                ss1:=ss1+ss[k];
            if ss=ss1 then
                begin
                    res:=res+(i-h-1)*60+(60+j-p);
                    writeln(res);
                    halt;
                end;
        end;
res:=res+(23-h)*60+60-p;
writeln(res);
end.

const fi='';
      fo='';
      maxn=1000000;

var   s,smin:string;
      b:array[1..maxn] of string;
      dem,min:longint;
procedure nhapdl;
begin
      readln(s);
      min:=0;
end;

procedure xuly;
var   i,j,c,t1,t2:longint;
      a,m:string;
begin
      a:='';
      if s[1] + s[2]=s[2] + s[1] then exit;
      for i:=0 to 23 do
           begin
                   j:=i;
                   str(j,a);
                   if (length(a)=1) and (a[1] <= '5') then
                                begin
                                        inc(dem);
                                        a:='0'+a+a[1]+'0';
                                        b[dem]:=a;
                                end
                   else if (a[2] <= '5') and (length(a)=2) then
                        begin
                                inc(dem);
                                a:=a + a[2] + a[1];
                                b[dem]:=a;
                        end;
                   a:='';
           end;
      delete(s,3,1);
      smin:='2400';
      for i:=1 to dem do
           if b[i] > s then
                begin
                        smin:=b[i];
                        break;
                end;
      if s[1]='0' then delete(s,1,1);
      if smin[1]='0' then delete(smin,1,1);
      val(s,t1,c);
      val(smin,t2,c);
      if (t2 mod 100 - t1 mod 100) > 0 then
                min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60
      else      begin
                        t2:=t2 - 40;
                        min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60;
                end;
      write(min);

end;

BEGIN
      assign(input, fi);reset(input);
      assign(output, fo);rewrite(output);
      nhapdl;
      xuly;
      close(input);close(output);
END.

const fi='';
      fo='';
      maxn=1000000;

var   s,smin:string;
      b:array[1..maxn] of string;
      dem,min:longint;
procedure nhapdl;
begin
      readln(s);
      min:=0;
end;

procedure xuly;
var   i,j,c,t1,t2:longint;
      a,m:string;
begin
      a:='';
      for i:=0 to 23 do
           begin
                   j:=i;
                   str(j,a);
                   if (length(a)=1) and (a[1] <= '5') then
                                begin
                                        inc(dem);
                                        a:='0'+a+a[1]+'0';
                                        b[dem]:=a;
                                end
                   else if (a[2] <= '5') and (length(a)=2) then
                        begin
                                inc(dem);
                                a:=a + a[2] + a[1];
                                b[dem]:=a;
                        end;
                   a:='';
           end;
      delete(s,3,1);
      smin:='2400';
      for i:=1 to dem do
           if b[i] >= s then
                begin
                        smin:=b[i];
                        break;
                end;
      if s[1]='0' then delete(s,1,1);
      if smin[1]='0' then delete(smin,1,1);
      val(s,t1,c);
      val(smin,t2,c);
      if (t2 mod 100 - t1 mod 100) > 0 then
                min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60
      else      begin
                        t2:=t2 - 40;
                        min:=min + (t2 mod 100 - t1 mod 100) + (t2 div 100 - t1 div 100) * 60;
                end;
      write(min);

end;

BEGIN
      assign(input, fi);reset(input);
      assign(output, fo);rewrite(output);
      nhapdl;
      xuly;
      close(input);close(output);
END.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if ((m>l) or ((m=l) and (c>j))) and (m3<>59) then begin write(m2-m3);exit;end;

k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;

if k=6 then begin h:=h+60;k:=k+1;end;
if k=7 then begin h:=h+60;k:=k+1;end;
if k=8 then begin h:=h+60;k:=k+1;end;
if k=9 then begin h:=h+60;k:=k+1;end;
if k=16 then begin h:=h+60;k:=k+1;end;
if k=17 then begin h:=h+60;k:=k+1;end;
if k=18 then begin h:=h+60;k:=k+1;end;
if k=19 then begin h:=h+60;k:=k+1;end;

if k=0 then begin write(h);exit;end;

h:=h+(k mod 10)*10+(k div 10);
write(h);
end.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;

if (l>=m) then k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;
if k=0 then begin write(h);exit;end;

h:=h+((m+1)*10+c);
write(h);
end.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;

if (l>=m) then k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;

if k=6 then begin h:=h+60;k:=k+1;end;
if k=7 then begin h:=h+60;k:=k+1;end;
if k=8 then begin h:=h+60;k:=k+1;end;
if k=9 then begin h:=h+60;k:=k+1;end;

if k=0 then begin write(h);exit;end;

h:=h+(k mod 10)*10+(k div 10);
write(h);
end.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if (m>l) then begin write(m2-m3);exit;end;

if (l>=m) then k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;
if k=0 then begin write(h);exit;end;

h:=h+((m+1)*10+c);
write(h);
end.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;

if (l>=m) then k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;

if k=6 then begin h:=h+60;k:=k+1;end;
if k=7 then begin h:=h+60;k:=k+1;end;
if k=8 then begin h:=h+60;k:=k+1;end;
if k=9 then begin h:=h+60;k:=k+1;end;

if k=0 then begin write(h);exit;end;

h:=h+(k div 10)+(k mod 10);
write(h);
end.

var
m1,c1,k1,l1,j1:char;
m,c,k,l,j,m3,m2,h:integer;
begin
read(c1,m1,k1,l1,j1);
c:=ord(c1)-48;m:=ord(m1)-48;l:=ord(l1)-48;j:=ord(j1)-48;

if (m=l) and (c=j) then begin write(0);exit;end;
m3:=l*10+j;m2:=m*10+c;
if (m>l) or ((m=l) and (c>j)) then begin write(m2-m3);exit;end;

if (l>=m) then k:=c*10+m+1;
if k>23 then k:=0;
h:=60-m3;

if k=6 then begin h:=h+60;k:=k+1;end;
if k=7 then begin h:=h+60;k:=k+1;end;
if k=8 then begin h:=h+60;k:=k+1;end;
if k=9 then begin h:=h+60;k:=k+1;end;
if k=16 then begin h:=h+60;k:=k+1;end;
if k=17 then begin h:=h+60;k:=k+1;end;
if k=18 then begin h:=h+60;k:=k+1;end;
if k=19 then begin h:=h+60;k:=k+1;end;

if k=0 then begin write(h);exit;end;

h:=h+(k mod 10)*10+(k div 10);
write(h);
end.

uses math;
var n,m,i,j,ans:longint;
    a:array[0..100100]of longint;
    s:string;
    flag:boolean;
    c1,c2,c3,c4,c5:char;

function check:boolean;
begin if (c1+c2)=(c5+c4) then exit(true);exit(false);end;

procedure nx;
begin
  if c5 in ['0'..'8'] then c5:=chr(ord(c5)+1) else begin
    c5:='0';c4:=chr(ord(c4)+1);
  end;
  if c4='6' then begin
    c4:='0';c2:=chr(ord(c2)+1);
  end;
  if (c1='2')and(c2='4') then begin
    c1:='0';c2:='0';
  end;
end;

begin
readln(c1,c2,c3,c4,c5);
ans:=0;
while not check do begin inc(ans);nx;end;
writeln(ans);
end.

var st,s1,s2:string;
    so1,so2,i,j,code,d:longint;
function kt(s:string):boolean;
var i:longint;
begin
     for i:=1 to length(s) div 2 do
        if s[i]<>s[length(s)+1-i] then exit(false);
     exit(true);
end;
begin
     read(st);
     s1:=st[1]+st[2];
     s2:=st[4]+st[5];
     val(s1,so1,code);
     val(s2,so2,code);
     for i:=so1 to so1+1 do
        begin
             for j:=so2 to 59 do
                begin
                     str(i,s1);
                     str(j,s2);
                     if length(s1)=1 then s1:='0'+s1;
                     if s1='24' then s1:='00';
                     if length(s2)=1 then s2:='0'+s2;
                     st:=s1+':'+s2;
                     inc(d);
                     if kt(st) then begin
                                          write(d-1);
                                          halt;
                                    end;
                 end;
            so2:=0;
        end;
end.

var	s,h,m:ansistring;
	a,h2,m2,m3:longint;

begin
	readln(s);
	h:=copy(s,1,2);
	m:=copy(s,4,2);
	if h[2]=m[1] then
		if h[1]=m[2] then
		begin
			writeln(0);
			halt;
		end;
	val(h,h2,a);
	val(m,m2,a);
	m:='';
	m:=m+h[2];
	m:=m+h[1];
	val(m,m3,a);
	if m3>m2 then
	begin
		writeln(m3-m2);
		halt;
	end;
	inc(h2);
	if h2=24 then h:='00' else str(h2,h);
	m:='';
	m:=m+h[2];
	m:=m+h[1];
	val(m,m3,a);
	writeln(60-m2+m3);
end.

var	s,h,m:ansistring;
	a,h2,m2,m3:longint;

begin
	readln(s);
	h:=copy(s,1,2);
	m:=copy(s,4,2);
	if h[2]=m[1] then
		if h[1]=m[2] then
		begin
			writeln(0);
			halt;
		end;
	val(h,h2,a);
	val(m,m2,a);
	m:='';
	m:=m+h[2];
	m:=m+h[1];
	val(m,m3,a);
	if m3>m2 then
	begin
		writeln(m3-m2);
		halt;
	end;
	inc(h2);
	if h2=24 then h:='00';
	m:='';
	m:=m+h[2];
	m:=m+h[1];
	val(m,m3,a);
	writeln(60-m2+m3);
end.

var h,m,q,sum,i,j,n:longint;
    s:string;
function qwe(x,y:longint):boolean;
begin
 if (x div 10=y mod 10)and(y div 10=x mod 10) then
 qwe:=true else
 qwe:=false;
end;
begin
 readln(s);
 val(s[1]+s[2],h,q);
 val(s[4]+s[5],m,q);
 sum:=0;
 for  i:=h to 23 do
  for  j:=0 to 59 do
   if (qwe(i,j))and((i=h)xor(j<m))then
   begin
    writeln(sum);
    exit;
   end else
   if not((i=h)and(j<=m)) then
   inc(sum);
 writeln(sum+1);
end.

var h,m,q,sum,i,j,n:longint;
    s:string;
function qwe(x,y:longint):boolean;
begin
 if (x div 10=y mod 10)and(y div 10=x mod 10) then
 qwe:=true else
 qwe:=false;
end;
begin
 readln(s);
 val(s[1]+s[2],h,q);
 val(s[4]+s[5],m,q);
 sum:=0;
 for  i:=h to 23 do
  for  j:=0 to 59 do
   if (qwe(i,j))and((i=h)xor(j<m))then
   begin
    writeln(sum);
    exit;
   end else
   if not((i=h)and(j<m)) then
   inc(sum);
 writeln(sum);
end.

var s:string; a,b,c,t1,t2:longint;
begin
  readln(s);
  val(s[1],t1); val(s[2],t2);
  a:= t1 + t2*10;
  val(s[4],t1); val(s[5],t2);
  b:= t1*10 + t2 ;
  c:=0;
  while a<>b do begin
	inc(b);inc(c);
	if b=60 then begin inc(a,10); b:=0;
	  if a mod 100 = 0 then a:=(a div 100)+1;
	end;
	if a = 42 then a:=0;
  end;
  writeln(c);
end.

var s: string[5];
    h, m, log: LongInt;

function reverse(n: LongInt): LongInt;
var t, v: string;
    a: LongInt;
begin
    t := '';
    while (n > 0) do
     begin
        str(n mod 10, v);
        t := t + v;
        n := n div 10;
     end;
    val(t, a, log);
    if (a < 10) then a := a * 10;
    reverse := a;
end;

begin
    read(s);
    val(copy(s, 1, 2), h, log);
    val(copy(s, 4, 2), m, log);

    if (h = 23) then
     begin
        if (m = 32) then write(0) else write(60 - m);
        halt;
     end;

    if (reverse(m) = h) then write(0)
    else
     begin
        if (m > reverse(h)) then
            write(reverse(h + 1) + (60 - m))
        else
            write(reverse(h) - m);
     end;
end.

Uses math;
Var fi, fo: text;
    s, sh, sm: string;
    h, m, i, j, res: Longint;

Begin
	assign(fi,''); reset(fi);
	assign(fo,''); rewrite(fo);
	readln(fi, s);
	h:= (ord(s[1]) - 48)*10 + ord(s[2]) - 48;
	m:= (ord(s[4]) - 48)*10 + ord(s[5]) - 48;
	for i:=h to 24 do
	begin
		if i=24 then sh:= '00'
		else
			if (i div 10)=0 then sh:= '0' + chr(i+48)
			else str(i, sh);
		if i=h then
		begin
			for j:=m to 59 do
			begin
				if j=60 then sm:= '00'
				else
					if (j div 10)=0 then sm:= '0' + chr(j+48)
					else str(j, sm);
				if (sh[1]+sh[2])=(sm[2]+sm[1]) then
				begin
					writeln(fo, res);
					close(fi); close(fo);
					exit;
				end;
				inc(res);
			end;
		end
		else
		begin
			for j:=0 to 59 do
			begin
				if j=60 then sm:= '00'
				else
					if (j div 10)=0 then sm:= '0' + chr(j+48)
					else str(j, sm);
				if (sh[2]+sh[1])=(sm[2]+sm[1]) then
				begin
					writeln(fo, res);
					close(fi); close(fo);
					exit;
				end;
				inc(res);
			end;
		end;
	end;
End.

const fi='';
      fo='';
var st,h,m:string;
procedure openf;
begin
   assign(input,fi);
   reset(input);
   assign(output,fo);
   rewrite(output);
end;
procedure closef;
begin
   close(input);
   close(output);
end;
procedure solve;
var g,p,kq:longint;
begin
   readln(st);
   h:=st[1]+st[2];
   m:=st[4]+st[5];
   kq:=0;
   repeat
       if(h[1]=m[2]) and (h[2]=m[1]) then
       begin
         write(kq);
         break;
       end;
       inc(kq);
       val(m,p);
       inc(p);
       if p=60 then
       begin
         val(h,g);
         inc(g);
         if  g=24 then h:='00';
         m:='00';
         if (h='00') and (m='00') then
         begin
            write(kq);
            exit;
         end;
       end
       else
       begin
         str(p,m);
         if p <10 then m:='0'+m;
       end;

   until false;
end;
BEGIN
   openf;
   if (h='00') and (m='00') then write(0) else
   solve;
   closef;
END.

var
a,k,n,i,j,min,h,a1,a2:integer;
inp:string;
begin
min:=0;
h:=0;
K:=0;
read(inp);
val(inp[1..2],h,a1);
val(inp[4..5],min,a2);

for i:=1 to 999999 do
 begin
  if (min mod 10 = min div 10) and (h mod 10 = h div 10) then
  break;
  if (min mod 10 <> h div 10) or (h mod 10 <> min div 10) then
  min:=min+1;
  if min>59 then
  begin
 // h:=h+1;
  min:=0;
 end;
 end;
// min:=h*60+min;
 write(min);
end.

var
a,k,n,i,j,min,h,a1,a2:integer;
inp:string;
begin
min:=0;
h:=0;
K:=0;
read(inp);
val(inp[1..2],h,a1);
val(inp[4..5],min,a2);

for i:=1 to 999999 do
 begin

  if (min mod 10 = h div 10) and (h mod 10 = min div 10) then
  break;
  if (min mod 10 <> h div 10) or (h mod 10 <> min div 10) then
  min:=min+1;
  if min>59 then
  begin
 h:=h+1;
  min:=0;
 end;
 end;
min:=h*60+min;
i:=i-1;
 write(i);

end.

var s0,s1,s2,s3,s4:string;
h1,h2,m1,m2,hp1,hp2,mp1,mp2,min,err: integer;
begin
        readln (s0);
        s1:=s0[1];
        s2:=s0[2];
        s3:=s0[4];
        s4:=s0[5];
        val(s1,h1,err);
        val(s2,h2,err);
        val(s3,m1,err);
        val(s4,m2,err);
        if (h1=m2) and (h2=m1) then min:=0
        else begin
                if h2>5 then begin
                        hp1:=h1+1;
                        hp2:=0;
                end else
                if (m1<h2) or ((m1=h2) and (m2<h1))
                then begin
                        hp1:=h1;
                        hp2:=h2;
                end  else
                begin
                  hp1:=h1;
                  hp2:=h2+1;
                end;
                mp1:=hp2;
                mp2:=hp1;
                min:= (hp1*10+hp2)*60+mp1*10+mp2-((h1*10+h2)*60+m1*10+m2)

        end;
        writeln(min);

end.

var s0,s1,s2,s3,s4:string;
h1,h2,m1,m2,hp1,hp2,mp1,mp2,min,err: integer;
begin
        readln (s0);
        s1:=s0[1];
        s2:=s0[2];
        s3:=s0[4];
        s4:=s0[5];
        val(s1,h1,err);
        val(s2,h2,err);
        val(s3,m1,err);
        val(s4,m2,err);
        if (h1=m2) and (h2=m1) then min:=0
        else begin
                if (h1=2) and (h2=3) and (m1*10+m2>32)
                then
                  min:=60-(m1*10+m2)
                else
                begin
                if h2>=5 then begin
                        hp1:=h1+1;
                        hp2:=0;
                end else
                if (m1<h2) or ((m1=h2) and (m2<h1))
                then begin
                        hp1:=h1;
                        hp2:=h2;
                end  else
                begin
                  hp1:=h1;
                  hp2:=h2+1;
                end;
                mp1:=hp2;
                mp2:=hp1;
                min:= (hp1*10+hp2)*60+mp1*10+mp2-((h1*10+h2)*60+m1*10+m2)
                end;

        end;
        writeln(min);

end.

var s0,s1,s2,s3,s4:string;
h1,h2,m1,m2,hp1,hp2,mp1,mp2,min,err: integer;
begin
        readln (s0);
        s1:=s0[1];
        s2:=s0[2];
        s3:=s0[4];
        s4:=s0[5];
        val(s1,h1,err);
        val(s2,h2,err);
        val(s3,m1,err);
        val(s4,m2,err);
        if (h1=m2) and (h2=m1) then min:=0
        else begin
                if h2>5 then begin
                        hp1:=h1+1;
                        hp2:=0;
                end else
                if (m1<=h2) and (m2<h1)
                then begin
                        hp1:=h1;
                        hp2:=h2;
                end  else
                begin
                  hp1:=h1;
                  hp2:=h2+1;
                end;
                mp1:=hp2;
                mp2:=hp1;
                min:= (hp1*10+hp2)*60+mp1*10+mp2-((h1*10+h2)*60+m1*10+m2)

        end;
        writeln(min);

end.

var s0,s1,s2,s3,s4:string;
h1,h2,m1,m2,hp1,hp2,mp1,mp2,min,err: integer;
begin
        readln (s0);
        s1:=s0[1];
        s2:=s0[2];
        s3:=s0[4];
        s4:=s0[5];
        val(s1,h1,err);
        val(s2,h2,err);
        val(s3,m1,err);
        val(s4,m2,err);
        if (h1=m2) and (h2=m1) then min:=0
        else begin
                if (h1=2) and (h2=3) and (m1*10+m2>32)
                then
                  min:=60-(m1*10+m2)
                else
                begin
                if h2>5 then begin
                        hp1:=h1+1;
                        hp2:=0;
                end else
                if (m1<h2) or ((m1=h2) and (m2<h1))
                then begin
                        hp1:=h1;
                        hp2:=h2;
                end  else
                begin
                  hp1:=h1;
                  hp2:=h2+1;
                end;
                mp1:=hp2;
                mp2:=hp1;
                min:= (hp1*10+hp2)*60+mp1*10+mp2-((h1*10+h2)*60+m1*10+m2)
                end;

        end;
        writeln(min);

end.

var
	h	: array [1..5] of char;
	n	: array [1..4] of integer;
	i	: integer;

function dif(a,b,c,d:integer): integer;
begin
	dif:=60+(b-c)*10+(a-d);
end;

function int(c: char): integer;
begin
	case c of
		'1': int:=1;
		'2': int:=2;
		'3': int:=3;
		'4': int:=4;
		'5': int:=5;
		'6': int:=6;
		'7': int:=7;
		'8': int:=8;
		'9': int:=9;
		'0': int:=0;
	end;
end;

begin
	readln(h);
	for i:=1 to 4 do
	begin
		if (i<3) then
			n[i]:=int(h[i])
		else
			n[i]:=int(h[i+1])
	end;

	if n[2] < 6 then
	begin
		if n[2]<n[3] then
		begin
			inc(n[2]);
			if n[2]=4 then
				if n[1]=2 then
					writeln (dif(0,0,n[3],n[4]))
				else
					writeln (dif(n[1],n[2],n[3],n[4]))
			else
				writeln (dif(n[1],n[2],n[3],n[4]));
		end else
		if n[2]=n[3] then
			if n[1]<n[4] then
			begin
				inc(n[2]);
				if n[2]=4 then
					if n[1]=2 then
						writeln (dif(0,0,n[3],n[4]))
					else
						writeln (dif(n[1],n[2],n[3],n[4]))
				else
					writeln (dif(n[1],n[2],n[3],n[4]));
			end else
				writeln (dif(n[1],n[2],n[3],n[4])-60)
		else
			writeln (dif(n[1],n[2],n[3],n[4])-60)
	end else
		writeln ((9-n[2])*60+dif(n[1]+1,0,n[3],n[4]));
end.

var
	h	: array [1..5] of char;
	n	: array [1..4] of integer;
	i	: integer;

function dif(a,b,c,d:integer): integer;
begin
	dif:=60+(b-c)*10+(a-d);
end;

function int(c: char): integer;
begin
	case c of
		'1': int:=1;
		'2': int:=2;
		'3': int:=3;
		'4': int:=4;
		'5': int:=5;
		'6': int:=6;
		'7': int:=7;
		'8': int:=8;
		'9': int:=9;
		'0': int:=0;
	end;
end;

begin
	readln(h);
	for i:=1 to 4 do
	begin
		if (i<3) then
			n[i]:=int(h[i])
		else
			n[i]:=int(h[i+1])
	end;

	if n[2] < 5 then
	begin
		if n[2]<n[3] then
		begin
			inc(n[2]);
			if n[2]=4 then
				if n[1]=2 then
					writeln (dif(0,0,n[3],n[4]))
				else
					writeln (dif(n[1],n[2],n[3],n[4]))
			else
				writeln (dif(n[1],n[2],n[3],n[4]));
		end else
		if n[2]=n[3] then
			if n[1]<n[4] then
			begin
				inc(n[2]);
				if n[2]=4 then
					if n[1]=2 then
						writeln (dif(0,0,n[3],n[4]))
					else
						writeln (dif(n[1],n[2],n[3],n[4]))
				else
					writeln (dif(n[1],n[2],n[3],n[4]));
			end else
				writeln (dif(n[1],n[2],n[3],n[4])-60)
		else
			writeln (dif(n[1],n[2],n[3],n[4])-60)
	end else
	if n[2]>5 then
		writeln ((9-n[2])*60+dif(n[1]+1,0,n[3],n[4]))
	else
		if n[2]=n[3] then
			if n[1]<n[4] then
				writeln (240+dif(1,0,n[3],n[4]))
			else
				writeln (dif(n[1],n[2],n[3],n[4])-60)
		else
			writeln (dif(n[1],n[2],n[3],n[4])-60);

end.

var     m,h:longint;

procedure nhap;
var     code:longint;
        s:string;
begin
        readln(s);
        val(copy(s,1,2),h,code);
        val(copy(s,4,2),m,code);
end;

procedure xuli;
var     k:longint;
        t:longint;
begin
        if h<23 then
            begin
                if ((h>=10) and (h<=15) or (h>=20)) or ((h>=0) and (h<=4)) then
                    begin
                        k:=(h mod 10)*10+(h div 10);
                        if m<=k then t:=k-m
                        else
                            begin
                                if h=15 then
                                    begin
                                        t:=60-m;
                                        t:=t+60*4;
                                        t:=t+2;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        inc(h);
                                        k:=(h mod 10)*10+(h div 10);
                                        t:=t+k;
                                    end;
                            end;
                    end
                else
                    begin
                        if h<10 then
                            begin
                                if h=5 then
                                    begin
                                        k:=(h mod 10)*10+(h div 10);
                                        if m<=k then t:=k-m
                                        else
                                            begin
                                                t:=60-m;
                                                t:=t+4*60;
                                                t:=t+1;
                                            end;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        t:=60*(10-h-1);
                                        t:=t+1;
                                    end;
                            end
                        else
                            begin
                                 t:=60-m;
                                 t:=t+60*(20-h-10);
                                 t:=t+2;
                            end;
                    end;

            end
        else
            begin
                k:=(h mod 10)*10+(h div 10);
                if m<=k then t:=k-m
                else t:=60-m;
            end;
        writeln(t);
end;

begin
        //assign(input,'816_a.inp');reset(input);
        //assign(output,'816_a.out');rewrite(output);
                nhap;
                xuli;
end.

var     m,h:longint;

procedure nhap;
var     code:longint;
        s:string;
begin
        readln(s);
        val(copy(s,1,2),h,code);
        val(copy(s,4,2),m,code);
end;

procedure xuli;
var     k:longint;
        t:longint;
begin
        if h<23 then
            begin
                if (h<16) or (h>=20) then
                    begin
                        k:=(h mod 10)*10+(h div 10);
                        if m<=k then t:=k-m
                        else
                            begin
                                if h=15 then
                                    begin
                                        t:=60-m;
                                        t:=t+60*4;
                                        t:=t+2;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        inc(h);
                                        k:=(h mod 10)*10+(h div 10);
                                        t:=t+k;
                                    end;
                            end;
                    end
                else
                    begin
                        t:=60-m;
                        t:=t+60*(20-h-1);
                        t:=t+2;
                    end;

            end
        else
            begin
                k:=(h mod 10)*10+(h div 10);
                if m<=k then t:=k-m
                else t:=60-m;
            end;
        writeln(t);
end;

begin
        //assign(input,'816_a.inp');reset(input);
        //assign(output,'816_a.out');rewrite(output);
                nhap;
                xuli;
end.

var     m,h:longint;

procedure nhap;
var     code:longint;
        s:string;
begin
        readln(s);
        val(copy(s,1,2),h,code);
        val(copy(s,4,2),m,code);
end;

procedure xuli;
var     k:longint;
        t:longint;
begin
        if h<23 then
            begin
                if (h<16) or (h>=20) then
                    begin
                        k:=(h mod 10)*10+(h div 10);
                        if m<=k then t:=k-m
                        else
                            begin
                                if h=15 then
                                    begin
                                        t:=60-m;
                                        t:=t+60*4;
                                        t:=t+2;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        inc(h);
                                        k:=(h mod 10)*10+(h div 10);
                                        t:=t+k;
                                    end;
                            end;
                    end
                else
                    begin
                        t:=60-m;
                        t:=t+60*(20-h-1);
                        t:=t+2;
                    end;

            end
        else  t:=60-m;
        writeln(t);
end;

begin
        //assign(input,'816_a.inp');reset(input);
        //assign(output,'816_a.out');rewrite(output);
                nhap;
                xuli;
end.

var     m,h:longint;

procedure nhap;
var     code:longint;
        s:string;
begin
        readln(s);
        val(copy(s,1,2),h,code);
        val(copy(s,4,2),m,code);
end;

procedure xuli;
var     k:longint;
        t:longint;
begin
        if h<23 then
            begin
                if ((h>=10) and (h<=15) or (h>=20)) or ((h>=0) and (h<=4)) then
                    begin
                        k:=(h mod 10)*10+(h div 10);
                        if m<=k then t:=k-m
                        else
                            begin
                                if h=15 then
                                    begin
                                        t:=60-m;
                                        t:=t+60*4;
                                        t:=t+2;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        inc(h);
                                        k:=(h mod 10)*10+(h div 10);
                                        t:=t+k;
                                    end;
                            end;
                    end
                else
                    begin
                        if h<10 then
                            begin
                                if h=5 then
                                    begin
                                        k:=(h mod 10)*10+(h div 10);
                                        if m<=k then t:=k-m
                                        else
                                            begin
                                                t:=60-m;
                                                t:=t+4*60;
                                                t:=t+1;
                                            end;
                                    end
                                else
                                    begin
                                        t:=60-m;
                                        t:=t+60*(10-h-1);
                                        t:=t+1;
                                    end;
                            end
                        else
                            begin
                                 t:=60-m;
                                 t:=t+60*(20-h-10);
                                 t:=t+2;
                            end;
                    end;

            end
        else
            begin
                k:=(h mod 10)*10+(h div 10);
                if m<=k then t:=k-m
                else t:=60-m;
            end;
        writeln(t);
end;

begin
        //assign(input,'816_a.inp');reset(input);
        //assign(output,'816_a.out');rewrite(output);
                nhap;
                xuli;
end.

var     f1,f2:text;
        st,sh,sm,dx:string;
        x,y,er,m:integer;
begin
        assign(f1,'');
        reset(f1); readln(f1,st); close(f1);

        sh:= copy(st,1,2); sm:= copy(st,4,2); dx:= sh[2]+sh[1];
        val(dx,x,er); val(sm,y,er);
        if x>=y then m:=x-y else
        begin
                x:=x+10;
                if x=42 then x:=0;
                m:= (60-y)+x;
        end;
        assign(f2,'');
        rewrite(f2);
        writeln(f2,m);
        close(f2);
end.

const fi='';
      fo='';
var  c:array [1..5] of char;
     a:array [1..4] of longint;
     h,m:longint;
function tim(a:longint):longint;
var x,y,z:longint;
begin
   y:=a;
   x:=y mod 10;
   y:=y div 10;
   for z:=m to 59 do if z=10*x+y then exit(a*60+z-h*60-m);
   exit(tim(a+1));
end;
procedure doc;
var i:longint;
begin
  assign(input,fi);reset(input);
  assign(output,fo);rewrite(output);
  for i:=1 to 5 do read(c[i]);
  val(c[1],a[1]);val(c[2],a[2]);val(c[4],a[3]);val(c[5],a[4]);
  h:=a[1]*10+a[2];m:=a[3]*10+a[4];
  write(tim(h));
  close(input);close(output);
end;
begin
  doc;
end.

const fi='';
      fo='';
var  c:array [1..5] of char;
     a:array [1..4] of longint;
     h,m:longint;
function tim(a,b:longint):longint;
var x,y,z:longint;
begin
   y:=a;
   x:=y mod 10;
   y:=y div 10;
   for z:=b to 59 do if z=10*x+y then exit(a*60+z-h*60-m);
   exit(tim(a+1,0));
end;
procedure doc;
var i:longint;
begin
  assign(input,fi);reset(input);
  assign(output,fo);rewrite(output);
  for i:=1 to 5 do read(c[i]);
  val(c[1],a[1]);val(c[2],a[2]);val(c[4],a[3]);val(c[5],a[4]);
  h:=a[1]*10+a[2];m:=a[3]*10+a[4];
  write(tim(h,m));
  close(input);close(output);
end;
begin
  doc;
end.

var a,b,c,d,s,o:longint;strok:string;
BEGIN
readln(strok);
val(strok[1],a,o);
val(strok[2],b,o);
val(strok[4],c,o);
val(strok[5],d,o);
while (A<>D)or(b<>c) do
begin
if (a=d)and(b=c)then break;
s:=s+1;
d:=d+1;
if d=10 then begin d:=0;c:=c+1;end;
if c=6  then begin c:=0;b:=b+1;end;
if b=9  then begin b:=0;a:=a+1;end;
if (a=2)and(b=4)then begin a:=0;b:=0;end;
end;
writeln(s);
end.

var a,b,c,d,s,o:longint;strok:string;
BEGIN
readln(strok);
val(strok[1],a,o);
val(strok[2],b,o);
val(strok[4],c,o);
val(strok[5],d,o);
o:=1;
while o=1 do
begin
if (a=d)and(b=c)then break;
s:=s+1;
d:=d+1;
if d=10 then begin d:=0;c:=c+1;end;
if c=6  then begin c:=0;b:=b+1;end;
if b=9  then begin b:=0;a:=a+1;end;
if (a=2)and(b=4)then begin a:=0;b:=0;end;
end;
writeln(s);
end.

program O_O;
type
        ll=longint;
var
        a,b,c,d,n:ll;
        s:shortstring;
begin
        readln(s);
        n:=0;
        val(s[1],a);val(s[2],b);val(s[4],c);val(s[5],d);
        while not ((a=d)and(b=c))do
        begin
                inc(n);
                if d<9 then inc(d)
                else begin
                        d:=0;
                        if c<5 then inc(c)
                        else begin
                                c:=0;
                                if (b<9)and(a<2) then inc(b)
                                else if (b<3)and(a<3) then inc(b)
                                else begin
                                        b:=0;
                                        if a<1 then inc(a)
                                        else begin
                                                a:=0;
                                             end;
                                     end;
                             end;
                     end;
        end;
        writeln(n);
end.

var s,x:string;
       k,f,i,p,g,a,b:longint;
begin
readln(s);
k:=0;
f:=0;
while f=0 do begin
p:=0;
for i:=1 to 2 do if (s[i]<>s[5-i+1])then p:=1;
if p=0 then begin
writeln(k);
f:=1;
exit;
end;
val(copy(s,1,2),a,g);
val(copy(s,4,2),b,g);
b:=b+1;
if b>=60 then begin
b:=0;
a:=a+1;
end;
if A>=24 then a:=0;
s:='';
if a<10 then begin
str(a,x);
s:='0'+x+':';
end
else begin
str(a,x);
s:=x+':';
end;
if b<10 then begin
str(b,x);
s:=s+'0'+x;
end
else begin
str(b,x);
s:=s+x;
end;
k:=k+1;
for i:=1 to 10000000do f:=0;
writeln(s);
end;
end.

var st:string;A:array[0..25] of string;
procedure       mo;
begin
        assign(input,'test.inp');reset(input);
        assign(output,'test.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;
function        dao(st:string):string;
var s:string;i:longint;
begin
        s:='';
        for i:=length(st) downto 1 do
                s:=s+st[i];
        exit(s);
end;
procedure       nhap;
var s:string;i:longint;
begin
        readln(st);
        for i:=0 to 23 do
                begin
                str(i,s);
                if length(s)<=1 then s:='0'+s;
                S:=s+':'+dao(s);
                A[i]:=s;
                end;
                A[24]:=A[0];
end;
procedure       xuli;
var s,ss:string;n,code,i,x,y:longint;
begin

        s:=copy(st,1,2);
        val(s,n,code);
        ss:=copy(A[n],pos(':',st)+1,2);
        s:=copy(st,pos(':',st)+1,2);
        val(s,x,code);
        val(ss,y,code);
        if x<=y then
                begin
                writeln(y-x);
                halt;
                end;
        inc(n);
        ss:=copy(A[n],pos(':',st)+1,2);
        val(ss,y,code);
        writeln(y+60-x);
end;

begin
       // mo;
        nhap;
        xuli;
        //dong;
end.

var s,s1,s2:string;
i,j,h,m,code,k,q:longint;
begin
read(s);
s1:=s[1]+s[2];
val(s1,h,code);
s1:=s[4]+s[5];
val(s1,m,code);
for i:=h to 23 do
for j:=m to 59 do begin
str(i,s2);
if i<10 then s1:='0'+s2+':' else s1:=s2+':';
str(j,s2);
if j<10 then s1:='0'+s1+s2 else s1:=s1+s2;
s2:='';
for q:=length(s1) downto 1 do
s2:=s2+s1[q];
if s2=s1 then begin writeln(k);exit;end;
inc(k);
end;
writeln(k);
End.

var s,s1,s2:string;
i,j,h,m,code,k,q:longint;
begin
read(s);
s1:=s[1]+s[2];
val(s1,h,code);
s1:=s[4]+s[5];
val(s1,m,code);
for i:=h to 23 do
for j:=0 to 59 do begin
str(i,s2);
if i<10 then s1:='0'+s2+':' else s1:=s2+':';
str(j,s2);
if j<10 then s1:=s1+'0'+s2 else s1:=s1+s2;
s2:='';
for q:=length(s1) downto 1 do
s2:=s2+s1[q];
if s1=s then k:=0;
if (s2=s1)and((i>=h)and(j>=m)) then begin writeln(k);exit;end;
inc(k);
end;
writeln(k);
End.

const fi='816A.inp';
        fo='816A.out';
var s,x:string;
        h,m,i,kq,c,k:longint;
function kt(h,m:longint):boolean;
        begin
                if (h=m) and ((m mod 10)*10+m < 24) then exit(true);
                if (m mod 10)*10+m div 10=h then exit(true);
                exit(false);
        end;
begin

        readln(s);
        x:=s[1]+s[2];val(x,h,c);
        x:=s[4]+s[5];val(x,m,c);
        for i:=1 to 1000000 do
                if kt(h,m) then break
                        else
                                begin
                                        inc(m);
                                        if m=60 then m:=0;
                                        if m=0 then inc(h);
                                        if h=24 then h:=0;
                   end;
        writeln(i-1);
end.

const fi='816A.inp';
        fo='816A.out';
var s,x:string;
        h,m,i,kq,c:longint;
function kt(h,m:longint):boolean;
        begin
                if h=m then exit(true);
                if (m mod 10)*10+m div 10=h then exit(true);
                exit(false);
        end;
begin

        readln(s);
        x:=s[1]+s[2];val(x,h,c);
        x:=s[4]+s[5];val(x,m,c);
        for i:=1 to 1000000 do
                if kt(h,m) then break
                        else
                                begin
                                        inc(m);
                                        if m=60 then m:=0;
                                        if m=0 then inc(h);
                                        if h=24 then h:=0;
                                end;
        writeln(i-1);
end.

var s,z:string;
min,i,k,y,x,j:longint;
a:array [00..1000005] of longint;
begin
min:=maxlongint;
        readln(s);
        for i:=0 to 1 do
                for j:=0 to 5 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+i)*60 + i*10+2;
                end;
        for i:=0 to 1 do
                for j:=0 to 5 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i+1440;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+i)*60 + i*10+2+1440;
                end;
        for i:=1 to 2 do
                z:=z+s[i];
        val(z,x);
        z:='';
        for i:=4 to 5 do
                z:=z+s[i];
        val(z,y);
        for i:=1 to k*2 do
                begin
                if abs(x*60+y-a[i])<min then min:=abs(x*60+y-a[i]);
                end;
        write(min);
end.

var s,z:string;
min,i,k,y,x,j:longint;
a:array [00..1000005] of longint;
begin
min:=maxlongint;
        readln(s);
        for i:=0 to 1 do
                for j:=0 to 5 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+j)*60 + j*10+2;
                end;
        for i:=0 to 1 do
                for j:=0 to 5 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i+1440;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+j)*60 + j*10+2+1440;
                end;
        for i:=1 to 2 do
                z:=z+s[i];
        val(z,x);
        z:='';
        for i:=4 to 5 do
                z:=z+s[i];
        val(z,y);
        for i:=1 to k*2 do
                begin
                if abs(x*60+y-a[i])<min then min:=abs(x*60+y-a[i]);
                end;
        write(min);
end.

var s,z:string;
min,i,k,y,x,j:longint;
a:array [00..1000005] of longint;
begin
min:=maxlongint;
        readln(s);
        for i:=0 to 1 do
                for j:=0 to 9 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+j)*60 + j*10+2;
                end;
        for i:=0 to 1 do
                for j:=0 to 9 do
                        begin
                        inc(k);
                        a[k]:=(i*10+j)*60 + j*10+i+1440;
                        end;
        for i:=0 to 4 do
                begin
                inc(k);
                a[k]:=(2*10+j)*60 + j*10+2+1440;
                end;
        for i:=1 to 2 do
                z:=z+s[i];
        val(z,x);
        z:='';
        for i:=4 to 5 do
                z:=z+s[i];
        val(z,y);
        for i:=1 to k*2 do
                begin
                if abs(x*60+y-a[i])<min then min:=abs(x*60+y-a[i]);
                end;
        write(min);
end.

var h,p,i,code,n,res,j,k:longint;
    cc,pp,s,ss,s1,ss1:string;

begin
read(s);
for i:=1 to length(s) do
    begin
        if s[i]=':' then break else cc:=cc+s[i];
    end;
val(cc,h,code);
for i:=i+1 to length(s) do
    begin
        pp:=pp+s[i];
    end;
val(pp,p,code);
for i:=h to 23 do
    For j:=p to 59 do
        begin
            str(i,s);
            if i<10 then s:='0'+s;
            str(j,s1);
            ss:=s+s1;
            ss1:='';
            for k:=length(ss) downto 1 do
                ss1:=ss1+ss[k];
            if ss=ss1 then
                begin
                    res:=res+(i-h-1)*60+(60+j-p);
                    writeln(res);
                    halt;
                end;
        end;
res:=res+(23-h)*60+60-p;
writeln(res);
end.

var s:string;
i,m,j:integer;
Function iny(s:string):string;
Var s1,s2:string;
m,n:integer;
Begin
s1:=s[1]+s[2];
s2:=s[4]+s[5];
m:=strtoint(s1);
n:=strtoint(s2);
if(n=59)then begin if(length(''+(m+1))=2)then  iny:=''+(m+1)+':'+'00' else iny:='0'+(m+1)+':'+'00' end else
begin
n:=n+1;if(length(''+m)=2)then iny:=''+(m)+':'+''+(n) else iny:='0'+(m)+':'+''+(n)
end;
end;
Begin

end.