 {$APPTYPE CONSOLE}
const nn=1000001; besk=200000000000000;
   nnn=2000000;  eps=1e-6; modul=1000000007;
 label 1,2,3,4;
var ii,jj,kt,ppp,god,day,mon,p,mask,i0,j0,k,step,i,j,start,finish,kol,m:longint;
p1,p2,ll,bb,pp,tt,ot1,ot2,s,kold,gr,n,ot,kolshok:int64;
ba,by,aa,ay,t,kk,centr,koef:int64;
flag2,flag1,flag:boolean;
ch:char;
aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;
x,c,b,a,rog,kop,perenos,shok:array[0..1000000] of int64;
marked,zan: array[0..330006] of boolean;
dist: array[0..4000,0..4000] of int64;
dd :double;
sss,ss1,ss:array[-1000..1100000] of char;
name:array[0..2000] of string;
function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  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 zaz(al:extended):extended;
begin  zaz:=(bb-pp*sin(al))*sin(al)/cos(al)+pp*cos(al)-aa;    end;

begin
 { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
  }
 read(p1,p2);
 if nod(p1,p2)<>1 then begin  write('Impossible'); goto 1; end;
 if p1>p2 then flag:=true;

 repeat
   begin
      inc(ot);
      if p1>p2 then
      begin x[ot]:=p1 div p2; p1:=p1 mod p2; goto 2;  end;
      if p1<p2 then
      begin x[ot]:=p2 div p1; p2:=p2 mod p1; goto 2;  end;

  2:
   end;
 until (p1=0)or(p2=0);

if flag then ch:='A' else ch:='B';

for  i:=1 to ot-1 do
begin
 write(x[i],ch); if ch='A' then ch:='B' else ch:='A';
end;
 write(x[ot]-1,ch) ;
 goto 1;
 writeln('--------');

  for ii:=1 to 12 do for jj:=1 to 12 do
begin
  for step:=1 to 12 do
    begin
        p:=1 shl step;

        for mask:=0 to p-1 do
          begin
             pp:=mask;
             aa:=1; by:=1;
             for i:=1 to step do  begin a[i]:=pp and 1; pp:=pp shr 1;   end;
             aa:=1; by:=1; ay:=0; ba:=0;
             for i:=1 to step do
           begin
               if a[i]=0 then
                 begin
                    ay:=ay+by;
                    aa:=aa+ba;

                 end else
                 begin
                    by:=by+ay;
                    ba:=ba+aa;

                 end;

            end;
          { for i:=1 to step do  write(a[i],' ');
           write(' == '); write(' ybl = ',ay,' ',by,' ');
           writeln(' apel = ',aa,' ',ba,' ');
          } if (aa+ba=ii)and(ay+by=jj)   then
             begin
                write(ii,' ',jj,' mask=  ');
                for i:=1 to step do write(a[i],' '); writeln;

             end;

           dist[aa+ba,ay+by]:=1;

          end;

    end;
end;
     for i:=1 to 30 do
     begin for j:=1 to 30 do if dist[i,j]=1 then write('+') else write('-'); writeln;  end;

   1:          close(output);
end.


program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
var
i,s,n,m,a,sum:integer;
begin
readln(n,s);
for I := 1 to n do
begin
read(a);
dec(s,a);
if a>m then m:=a;
end;
readln;
inc(s,m);
if s<0 then writeln('NO') else writeln('YES');
readln;
end.


uses    math;
const
        p1 = 'Timur';
        p2 = 'Marsel';
        oo = high(longint);
var
        m,n,k,e,i : longint;
begin
        readln(n,m,k);
        if n and 1 = 0 then
                writeln(p2)
        else begin
                e := oo;
                for i := 1 to trunc(sqrt(m)) do
                        if m mod i = 0 then begin
                                if i >= k then e := min(e,i) else
                                if m div i >= k then e := min(e,m div i);
                        end;
                if (e<m) then writeln(p1)
                else writeln(p2);
        end;
end.


var
  n1 : array[1..109] of longint;
  n,i,j,k,l,m : longint;
  s,s1 : string;
  c : char;

procedure qsortn1(l, r: longint);
var
  i, j, q, w: longint;
begin
  i := l;
  j := r;
  q := n1[(l + r) div 2];
  repeat
    while n1[i] < q do inc(i);
    while q < n1[j] do dec(j);
    if i <= j then
    begin
      w := n1[i];
      n1[i] := n1[j];
      n1[j] := w;
      inc(i);
      dec(j);
    end;
  until i > j;
  if l < j then qsortn1(l, j);
  if r > i then qsortn1(i, r);
end;

begin
      readln(n);

      for i := 1 to n do
      begin
            read(n1[i]);
      end;
      qsortn1(1,n);

      l := 1;
      k := 1;

      for i := 1 to n-1 do
      begin
           if n1[i] = n1[i+1] then
              inc(k);
           if (i = (n-1)) or ((n1[i] <> n1[i+1]))  then
           begin
              if k > l then
                l := k;
              k := 1;
           end;

      end;

      writeln(l);
end.


uses math;
var s:string;
    k,m,n,d,i:longint;
    c:integer;
begin
    readln(n,k);
    str(n,s);
    m:=10**k;
    n:=length(s);
    d:=0;
    val(s,k,c);
    if (k mod m=0) then
        begin
            writeln(d);
            exit;
        end;
    for i:=n downto 2 do
        begin
            if (s[i]<>'0') then
                begin
                    inc(d);
                    delete(s,i,1);
                    val(s,k,c);
                    if (k mod m=0) then
                        begin
                            writeln(d);
                            exit;
                        end;
                end;
        end;
    val(s,k,c);
    if (k mod m=0) then
        begin
            writeln(d+1);
            exit;
        end;
    writeln(d+length(s)-1);
end.


var a,s,d,f,g,h,j,k,i:longint;
q,w:array[1..1000] of longint;
e:array[1..1000] of char;
z:string;
begin
readln(a);
read(z);
for i:=2 to a do
if a mod i=0 then
begin
s:=s+1;
q[s]:=i;
end;
for i:=1 to s do begin
for j:=1 to q[i] do
e[j]:=z[j];
h:=q[i];
for j:=1 to q[i] do begin
z[j]:=e[h];
h:=h-1;
end;
end;
write(z);
end.


var
 y,b,r,i,j,k,s,max:longint;
begin
 read(y,b,r);
 s:=0;
 for i:=y downto 1 do
  for j:=b downto 1 do
   for k:=r downto 1 do
    if (j-1=i) and (k-1=j) then
     begin
      s:=i+j+k;
      if s>max then max:=s;
     end;
 write(max);
end.


var a,b,c,d:integer;
begin
readln(a,b,c,d);
if ((a=d) and (a<>0)) or ((a=0) and (c=0) and (d=0)) then writeln(1)
else writeln(0);
end.


program cfstepenice;
var n,m,d,c:integer;

begin
read(n,m);
d:=n div 2;
c:=n mod 2;
while (c+d) mod m<>0 do
        begin
        d:=d-1;
        c:=c+2;
        if d<0 then
                begin
                d:=0;
                c:=-1;
                break;
                end;
        end;
writeln(c+d);
end.


program z1;
var k1,k2,k3 : longint;
begin
readln(k1,k2,k3);
if (k1 = 1) or (k2 = 1 ) or (k3 = 1)
then write('YES')
else if (k1 = 2) and (k2 = 2 ) and (k3 <> 2)
               then write('YES')
               else if (k1 = 2) and (k3 = 2 ) and (k2 <> 2)
                    then write ('YES')
                    else if (k1 <> 2) and (k2 = 2 ) and (k3 = 2)
                         then write('YES')
                         else if (k1 = 3) and (k2 = 3 ) and (k3 = 3)
                              then write ('YES')
                              else if (k1 = 2) and (k2 = 4 ) and (k3 = 4)
                                   then write('YES')
                                   else if (k1 = 4) and (k2 = 2 ) and (k3 = 4)
                                        then write ('YES')
                                        else if (k1 = 4) and (k2 = 4 ) and (k3 = 2)
                                             then write('YES')
                                             else if (k1 = 2) and (k2 = 2 ) and (k3 = 2)
                                             then write('YES')
                                             else write('NO');
end.


var x,y,x1,x2,y1,y2:longint;
function xuly:string;
begin
if ABS(x2-x1) mod x <>0 then exit('NO');
if ABS(y2-y1) mod y <>0 then exit('NO');
if (ABS(x2-x1) div x) mod 2 <> (ABS(y2-y1) div y) mod 2 then exit('NO');
exit('YES');
end;

begin
//assign(input,'A.inp'); reset(input);
//assign(output,'A.out'); rewrite(output);
readln(x1,y1,x2,y2);
readln(x,y);
writeln(xuly);
//close(input); close(output);
end.


   const eps=0.0000000001;    nn=200000; besk=8000000000;
   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 zapas,dist,r,ll,rr,sum,q,h,pos,ot,t1,t2,pp,modul,t,tt,time,p,gr,qq,pmax,imax,p1,p2,p3,p4,l,nm,n,s1,s2,m,s,smin,cen,dl,i1:int64;
    ii,jj,step, k,i,j:longint;
     aa,bb,cc:int64;
     z,leftmax,leftmin,rightmax,rightmin,prev,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;
     dda:array[-10..1200,-10..1200] of int64;
   zanx,zany:array[-10..2000000] of boolean;
    marked,zan:array[-10..1000000] of boolean;
    ss, ss1,ss2:string;
     fl:array[0..200] of boolean;
    ch:char;
    d :array [0..100,-10..100,-10..100] of extended;
    dd:array [0..201,-10..30] of int64;
    sss:array[0..nn] of string;
    st2:array[0..nn] of string;
     v0,v1,s0,t0:extended;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;
     prob:array[-1..200,-1..200] of extended;

     yot:double;
       flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 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 degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
    read(aa,bb,dist,k);
    zapas:=bb;
    if bb<max(dist,aa-dist) then   begin write(-1); goto 1;  end;
     for i:=1 to k do if k>1 then
       begin
          if i=1 then begin inc(n); x[n]:=x[n-1]+dist;  end;

          if (i>1)and(i<k)and odd(i) then
          begin inc(n); x[n]:=x[n-1]+2*dist;  end;

          if (i>1)and(i<k)and not odd(i) then
          begin inc(n); x[n]:=x[n-1]+2*(aa-dist);  end;

          if (i=k)and(i>1) and odd(i) then
          begin inc(n); x[n]:=x[n-1]+2*(dist); inc(n); x[n]:=k*aa;  end;

          if (i=k)and not odd(i) then
          begin inc(n); x[n]:=x[n-1]+2*(aa-dist); inc(n); x[n]:=k*aa;  end;

       end;

      if k=1 then begin  inc(n); x[n]:=x[n-1]+dist;inc(n); x[n]:=x[n-1]+aa-dist; goto 2; end;

  2:  {   for i:=0 to n do write(x[i],' '); writeln;
       }

       for i:=0 to n-1 do
          begin
             zapas:=zapas-(x[i]-x[i-1]);
             if zapas<0 then begin write(-1); goto 1;  end;
             t:=x[i+1]-x[i];
             if t>bb then begin write(-1); goto 1;  end;
             if (t>zapas)and(i>0) then begin inc(ot); zapas:=bb;  end;
         {    writeln('i= ',i,' zapas= ',zapas,' ot= ',ot);
          }
          end;

            writeln(ot);

   1:          close(output);
end.