                                  const eps=1e-12;
                      besk=2002000000000000000; label 4,1,3,2,44,22;
                type mas=array[-100..1200000+1] of int64;
                integer=longint;    zap=record p1,p2,p3:int64; end;
                zap1=^zap;
                var sdvig,start,dl,len,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto,num:longint;
                ss3,ss,ss1,ss2:string;
                qqq:zap;  pmin,bet,al:extended;
                ot1,ot2:zap;
                ver:array[-1..500,-1..5] of extended;
                verugad:array[-2..200,-2..200,-2..200] of extended;
                kolzan,qq,kol,chisl,znam,n,m,ttt,right,left,numpos,vx,vy,ans,up,down,xmin,xmax,ymin,ymax,imax,t3,qq1,qq2,q1,q2,ost,koll,w,pos,dx,dy,sum,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;
                  z,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean;  pl:longint;
                 vel,zapas,razn,oldll,oldrr,ppp,shag,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;
                  zzan,prost,marked,zan:array[-1000000..1000000] of boolean;
                  ll,rr,zpl,zmi,path,lx,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;
                  ppole:array[-1000000..3000000] of char;
                  str1,str2,stroka:array[-1000..1000000] of char;
                  dinam:array[-100000..1000000] of extended;
                  t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;
                  dd,ssumitog,profil,zzz:array[-10..2100,-10..2100] of int64;
                  sp,sss:array[-10..2000000] of string;
                  newpole,pole:array[-1..2100,-1..2700] of char;
                  blizpr,ddd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;
                  poss:int64;
                  ch:char;
                  ff,flagg1:boolean;
                  oldx,oldy,zz,numx,numy,xleft,xright,s,znach,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;
                  dddd:array[-10..5010,-10..5010] of int64;
                 function srav(i,j:longint):boolean; label 44;

                begin
                   if (a[i]<a[j]) then begin srav:=true; goto 44;  end;
                   if a[i]>a[j] then begin  srav:=false; goto 44;   end;
                   if a[i]=a[j] then if a1[i]<a1[j] then srav:=true else srav:=false;

                 44:
                end;

                procedure sl (k,l,m:integer);  {k- dlina, l,m - nachalo dvuh blokov}
                begin
                i:=l;j:=m; flag:=true; step:=0;while flag do begin
                if (srav(i,j)) then begin begin b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];end;
                inc(step);inc(i);
                {writeln('step=',step,' i=',i);} end;
                if (not srav(i,j)) then begin begin b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];end;
                inc(step);inc(j);end;
                if  ((i>=l+k) or (j>=m+k)) then flag:=false;
                end;
                if(i>=l+k) then repeat b[l+step]:=a[j];b1[l+step]:=a1[j];b2[l+step]:=a2[j];inc(step);inc(j);until (j>=m+k);
                if(j>=m+k) then repeat b[l+step]:=a[i];b1[l+step]:=a1[i];b2[l+step]:=a2[i];inc(step);inc(i);until (i>=l+k);
                end;
                procedure sort(var c:mas);

                begin

                k:=1; repeat
                l:=1;m:=k+l; repeat sl(k,l,m); l:=l+2*k;m:=m+2*k; until (l>=n); k:=k*2;
                for i:=1 to n do begin a[i]:=b[i];a1[i]:=b1[i];a2[i]:=b2[i]; end;
                until (k>=n);

                end;

                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 min3(a,b,c:int64):int64;  var ot:int64;
                begin ot:=a; if b<ot then ot:=b; if c<ot then ot:=c;  min3:=ot;  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;  fl:boolean;
begin
  fl:=false;
  if a<b then begin r:=a;a:=b;b:=r; fl:=true; 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;
    if not fl then begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end else
         begin d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=y;tt.p3:=x; tt1:=@tt; end;
   evkl:=tt1;
end;

                function phi(a,b:double):double; label 222;var p:double;
                begin
                  if (a>0)and (b>=0) then begin p:=arctan(b/a);goto 222; end;
                  if (a<0) then begin p:=pi+arctan(b/a);goto 222; end;
                  if (a>0)and (b<0) then begin p:=2*pi+arctan(b/a);goto 222; end;
                  if (a=0)and (b>0) then begin p:=pi/2;goto 222; end;
                  if (a=0)and (b<0) then begin p:=3*pi/2;goto 222; end;
                  222: phi:=p;
                end;

                function nod(a,b:int64):int64; var p,t:int64;
                begin
                  a:=abs(a); b:=abs(b);
                  if (a>0)and(b>0) then
                   begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
                    p:=a;
                   end else if a=0 then p:=b else p:=a;
                nod:=p;
                end;
          function arccos(tt:extended):extended;
  begin
    if abs(tt)>1-1e-13 then
    if tt>0 then  arccos:=0 else arccos:=pi;
    if tt=0 then arccos:=pi/2 else
    if abs(tt)<=1-1e-13 then if tt>=0 then arccos:=arctan(sqrt(1-tt*tt)/tt)
    else arccos:=pi+arctan(sqrt(1-tt*tt)/tt);

  end;

                function nok(a,b:int64):int64;
                begin  nok:=(a*b) div nod(a,b);  end;

                   function degg(a:int64;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;

      {          function zaprmax(left,right:longint):int64;
            begin
               if left>=right then zaprmax:=y[left] else
                 begin
                    if not odd(left) and odd(right) then zaprmax:=zaprmax(left shr 1,right shr 1) else
                     begin
                      if odd(left) then zaprmax:=max(zaprmax(left+1,right),y[left]);
                      if not odd(right) then zaprmax:=max(zaprmax(left,right-1),y[right]);

                     end;

                 end;

            end;
       }
          function zaprmin(left,right:longint):int64;
            begin
               if left>=right then zaprmin:=y[left] else
                 begin
                    if not odd(left) and odd(right) then zaprmin:=zaprmin(left shr 1,right shr 1) else
                     begin
                      if odd(left) then  zaprmin:=min(zaprmin(left+1,right),y[left]);
                      if not odd(right) then zaprmin:=min(zaprmin(left,right-1),y[right]);

                     end;

                 end;

            end;

                procedure udal(ii:longint);
                begin  next[prev[ii]]:=next[ii];prev[next[ii]]:=prev[ii];  end;

                function nomerr(gr:int64):int64;

                var ot,aa,bb,cc:int64; fl:boolean;
                begin
                  aa:=1; bb:=p;  cc:=aa; fl:=false;
                  while abs(aa-bb)>1 do
                    begin
                       cc:=(aa+bb) shr 1;
                       writeln('cc=++ ',cc);
                       if y[cc]<gr then aa:=cc else bb:=cc;

                    end;
                   writeln(' cc= ',cc);
                 {  cc:=max(cc-3,0);
                 }  repeat inc(cc) until y[cc]>=gr;
                   if y[cc]=gr then fl:=true else fl:=false;
                    if fl then nomerr:=a1[cc] else nomerr:=-1000;
                   nomerr:=cc;
                end;

                function pprost(pp:longint):boolean;
                var i,j,t:longint; tt:extended; fl:boolean;
                begin
                  tt:=pp;
                  tt:=sqrt(tt);
                  fl:=true;
                  for i:=2 to round(tt) do if pp mod i=0 then  fl:=false;

                 pprost:=fl;

                end;

                function gl(c:char):boolean;
                begin
                 if (c='a')or (c='o')or(c='e')or(c='i')or(c='u') then gl:=true else gl:=false;

                end;

function leftdig(t:longint):longint;
var p,i,j,ans:longint;
begin
   p:=0;
   while t>0 do begin inc(p); x[p]:=t mod 10; t:=t div 10;  end;
   leftdig:=x[p];
end;

 begin
  {  assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
   }
           { for i:=1 to 20 do writeln(i,' ',leftdig(i));
            }

         read(qq);
       for stepp:=1 to qq do
         begin
            read(p,kk,gr);
            for i:=1 to p do read(a[i]);
            for i:=1 to p do a1[i]:=i;
            n:=1; repeat n:=n*2 until n>p;
            for i:=p+1 to n do a[i]:=besk;
            sort(a);
            for i:=1 to p do y[a1[i]]:=i;
          q:=0;
           for i:=1 to p do if a[i]<>a[i-1] then x[i]:=x[i-1]+1 else x[i]:=x[i-1];
            for i:=1 to p do z[a1[i]]:=x[i];

         {  for i:=1 to p do write(z[i],' '); writeln;
         }  for i:=1 to p do xx[i]:=0;
           kolzan:=0; ans:=100000000;
           for i:=1 to p do zan[i]:=false;
           for i:=1 to gr do
             begin
                t:=z[i];
                if not zan[t] then
                  begin
                     inc(kolzan);
                     inc(xx[t]);
                     zan[t]:=true;

                  end else inc(xx[t]);

             { writeln('kolzan= ',kolzan);
              }
             end;

            ans:=kolzan;
           for i:=gr+1 to p do
             begin
                t:=z[i];
                t1:=z[i-gr];
                if not zan[t] then
                  begin
                     zan[t]:=true;
                     inc(xx[t]);
                     inc(kolzan);

                  end else inc(xx[t]);

                if  xx[t1]>1 then  dec(xx[t1]) else
                  begin
                     dec(xx[t1]);
                     zan[t1]:=false;
                     dec(kolzan);
                  end;

              { writeln('i= ',i,' kolzan= ',kolzan);
               }

               ans:=min(ans,kolzan);

             end;

            writeln(ans);

         end;

      1: close (output);
    end.


{ fp }
VAr
 s : string;
 n : int64;
 len,p : integer;

 begin
  ReadLn(s);
  len := length(s);
  If (len>19) or ((len=19) and (s>'9223372036854775807')) then WriteLn('BigInteger') else
   Begin
    Val(s,n,p);
    If N>2147483647 then WriteLn('long') else
    if n>32767 then WriteLn('int') else
    If n>127 then WriteLn('short') else
    WriteLn('byte');
   End;
 End.


var S : string[100];
    i, j, L, max : longint;
begin
     readln(S);
     L := length(S);
     For i := 1 to L do
         For j := L-i+1 downto 1 do
             If pos(copy(S,i,j),copy(S,i+1,length(S))) <> 0 then
                If j > max then max := j;
     writeln(max);
end.


uses math;
var
 n,c,i,maxn:longint;
 a:array[1..101] of longint;
begin
  maxn:=-maxlongint;
  read(n,c);
  for i:=1 to n do
   begin
    read(a[i]);
    if i>=2 then maxn:=max(maxn,a[i-1]-a[i]);
   end;
  if maxn>=c then write(maxn-c)
             else write('0');
end.


const inf=9000000000000000000;
var p, k : array[1..1000] of qword;
    n, b, bb, ans, kol, j, num, pn : qword;
    i, r : longint;
begin
  ans:=inf;
  readln(n, b);
  bb:=b;
  for i:=2 to trunc(sqrt(bb))+1 do
    if b mod i = 0 then begin
      inc(num);
      p[num]:=i;
      while b mod i = 0 do begin
        inc(k[num]);
        b:=b div i;
      end;
    end;
  if b > 1 then begin
    inc(num);
    p[num]:=b;
    k[num]:=1;
  end;
  for i:=1 to num do begin
    j:=p[i];
    for r:=1 to trunc(ln(n)/ln(j)) do begin
      inc(kol, n div j);
      j:=qword(j)*p[i];
    end;
    kol:=kol div k[i];
    if (ans > kol) then ans:=kol;
    kol:=0;
  end;
  writeln(ans);
end.


const fi='';
      fo='';
      maxn=100;
var n,m,bx,by:integer;
    x,y:array[0..maxn] of integer;
    ax,ay,base:int64;
procedure nhap;
  var i:integer;
  begin
        readln(n,bx);
        for i:=n downto 1 do read(x[i]);
        readln(m,by);
        for i:=m downto 1 do read(y[i]);
  end;
procedure xuly;
  var i:integer;
  begin
        ax:=0;base:=1;
        for i:=1 to n do
          begin ax:=ax+base*x[i];
                base:=base*bx;
          end;
        ay:=0;base:=1;
        for i:=1 to m do
          begin ay:=ay+base*y[i];
                base:=base*by;
          end;
        if ax=ay then write('=')
          else if (ax>ay) then write('>')
                else write('<');
  end;
begin
        assign(input,fi);reset(input);
        assign(output,fo);rewrite(output);
        nhap;
        xuly;
        close(input);close(output);
end.


var i,l,r,n,m,o,p,a,b,rr:int64;
begin
//assign(input,'it.in');reset(input);
//assign(output,'it.out');rewrite(output);
read(l,r,n,m);
if m mod n<>0 then
  begin
  write(0);
  close(input);close(output);halt;
  end;
o:=m div n;
while i<trunc(sqrt(o)) do
  begin
  inc(i);
  if o mod i=0 then
    if(i*n>=l)and(i*n<=r)and(o div i*n>=l)and(o div i*n<=r)then
      begin
      a:=i;b:=o div i;rr:=a mod b;
      while rr<>0 do
        begin
        a:=b;b:=rr;rr:=a mod b;
        end;
      if b=1 then
        begin
        inc(p);
        if i*i<>o then inc(p);
        end;
      end;
  end;
writeln(p);
close(input);close(output);
end.


program p1;
var i,j,m,n:smallint;min,t:integer; a:array [1..10000] of integer;
begin
readln(n,m);
min:=maxint;
for i:=1 to m do read(a[i]);
for i:=1 to m-1 do
for j:=i+1 to m do
if a[j]<a[i] then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
end;
for i:=1 to m-n+1 do
if a[i+n-1]-a[i]<min then min:=a[i+n-1]-a[i];
if min=maxint then min:=0;
writeln(min);
end.


{$Q-,R-,S-}
{$APPTYPE CONSOLE}

function droot(x: integer): integer;
begin
  result := x mod 9;
  if result = 0 then result := 9
end;

var x: array[1..9] of int64;

var n, i, j, k: integer;
    ans:int64;
begin
  read(n);
  fillchar(x, sizeof(x), 0);
  for i := 1 to n do inc(x[droot(i)]);
  ans := 0;
  for i := 1 to 9 do for j := 1 to 9 do for k := 1 to 9 do
      if droot(j*k) = i then ans := ans + x[i]*x[j]*x[k];
  for i := 1 to n do ans := ans - n div i;
  write(ans);
end.


program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
	k, r, i, j: Integer;

begin
	Readln(k, r);
	i := 1;
	while i<=10 do
	begin
		j := k*i;
		if ((j mod 10)=r) or ((j mod 10)=0) then
		begin
			Writeln(i);
			break;
		end;
		Inc(i);
	end;
end.


{$mode objfpc}
var
  n,s:int64;
  i:longint;
  a:array[0..10000]of int64;
begin
  readln(n);
  a[0]:=0;
  for i:=1 to n do
    read(a[i]);
  for i:=1 to n do
    begin
      if (a[i]=1)then inc(s);
      if (a[i]=0)and(a[i-1]=1)and(a[i+1]=1)then inc(s);
    end;
  writeln(s);
end.


//fpc 3.0.0

program HelloWorld;

var v:array[1..20] of byte;
vv,w:int64;
i,n,ans,bestans,j,r,z,o:longint;
bb:boolean;
begin
    readln(vv);

    n:=0;
    while (vv>0) do begin
        inc(n);
        v[n]:=vv mod 10;
        vv:=vv div 10;
    end;

    bestans:=-1;
    for i:=44721 downto 1 do begin
        w:=i*i; o:=w;
        j:=1;
        ans:=0;
        bb:=true;
        r:=0;
        while (w>0) do begin
          //  if (o=1444) then writeln(w,' ',j);
            r:=r+1;
            z:=w mod 10;
            while (v[j]<>z) do begin inc(j); if (j>n) then begin bb:=false; break;end; end;
            inc(j);
            w:=w div 10;

            end;
        ans:=(n-r);
        if (bb)and((ans<bestans)or(bestans=-1)) then begin
        //writeln(o);
            bestans:=ans;
            end;
    end;

    writeln(bestans);

end.


{ uses crt; }
    const nn=100;
    label 1,2;
    var p,n1, p2,n,i,j,k,na,nb,pmax:longint;
    pp:char;
    flag:boolean;
    l,r,x,y:array[0..nn] of longint;
     function min(i,j:longint):longint;
  begin min:=i; if j<i then min:=j;end;

     function max(i,j:longint):longint;
  begin max:=i; if j>i then max:=j;end;
     function nod(a,b:longint):longint;  var i,j:longint;
   begin while i>0 do begin i:=a mod b;a:=b;b:=i;    end;
     nod:=a;

   end;

     begin   { clrscr;

     assign(input,'input.txt');reset(input);
   }  for i:=1 to 3 do read(x[i]);
     for i:=1 to 3 do read(y[i]);
     p:=1;
     for i:=1 to 3 do p:=p*(x[i]-y[i]);
     if p<>0 then writeln('NO') else writeln('YES');

           close(output);

           end.


program Measuring_Lengths_in_Baden;
var n:integer;
begin
  readln(n);
  writeln(round(n/3) div 12,' ',round(n/3) mod 12);
end.


var
	a, b, n, c, c1, m, x, x1, x2, x3: integer;
	arr: array [1..115, 1..115] of char;
	s: string;

begin

	readln(n);
	for var i := 0 to n - 1 do
	begin
		read(x);
		a += x;
	end;

	for var i := 0 to n - 1 do
	begin
		read(x1);
		b += x1;
	end;

	if (a >= b) then
		writeln('YES')
	else
		writeln('NO');

end.


{$MACRO ON}
{$MODE OBJFPC}
{$COPERATORS ON}
{$DEFINE wait:=readln;readln;}
{$DEFINE maxN:=trunc(1e5)+1}

uses gvector,garrayutils,math;
const	fi='';
		fo='';
type
	TCustomType = int32;   //   <------ TYPE
	TPair = record x,y : int32; end;
	vector = specialize TVector<TCustomType>;
	vectorInt = specialize TVector<Int32>;
	vectorPair = specialize TVector<TPair>;
    compare = class
    	public
        	class function c(a,b : TCustomType) : boolean;
    end;
    utils = specialize TOrderingArrayUtils<vector,TCustomType,compare>;
class function compare.c(a,b : TCustomType) : boolean;
	begin Result := a<b; end;     //   <------ ORDER

var n,k,x : int32;
	a : array[0..101] of int32;

procedure readData();
	var i : int32;
    begin
    	readln(n,k,x);
		for i := 1 to n do begin
            read(a[i]);
		end;
    end;

procedure main();
    var i : int32;
		res : int32 = 0;
	begin
        readData();
		for i := n downto 1 do begin
            if (k>0) then begin
            	res += x;
				k -= 1;
			end else begin
                res += a[i];
			end;
		end;
		write(res);
		wait;
    end;

begin
    assign(input,fi); reset(input);
    assign(output,fo); rewrite(output);
	main();
    close(input); close(output);
end.


uses
 math, sysutils, strutils;
type
 ex=extended;
 int=longint;
 bool=boolean;
var
 i,n: int;
begin
readln(n);
if n<3
 then
  writeln(-1)
 else
  begin
  write('100 100');
  for i:= 1 to n-2 do
   write(#$20, i);
  end;
end.


var n,s:int64;

function check(x:int64):boolean;
var a,t:int64;
begin
    t := 0; a := x;
    while a > 0 do begin
        t := t + a mod 10;
        a := a div 10;
    end;
    exit(x - t >= s);
end;

procedure xuly();
var l,r,mid,ans:int64;
begin
    ans := 0;
    l := 0; r := n;
    while l <= r do begin
        mid := (l + r) div 2;
        if check(mid) then begin
            ans := n - mid + 1;
            r := mid - 1;
        end else l := mid + 1;
    end;
    writeln(ans);
end;

begin
    readln(n,s);
    xuly();
end.


var a,b:array[1..100] of longint;
    i,n,j,k:longint;
begin
read(n);
for i:=1 to n do
  read(a[i],b[i]);
k:=0;
for i:=1 to n do
  for j:=1 to n do
    begin
      if a[i]=b[j] then inc(k);
    end;
write(k);
end.


var
  n:longint;
begin
  readln(n);
  if (not odd(n)) and (n>2) then writeln('YES')
  else writeln('NO');
end.


var
n,i,F,S:int64;
a:string;
begin
  readln(n);
  read(a);
  for i := 2 to n do
    begin
    if (a[i-1]='F') and (a[i]='S') then
       F:=F+1;
    if (a[i]='F') and (a[i-1]='S') then
      S:=S+1;
  end;
  if S>F then write('YES') else write('NO');
end.


{$Q+,R+,O+}
var n,i,x,s,rez:LongInt;
begin
     //reset(input,'input.txt');
     //rewrite(output,'output.txt');
     readln(n);
     s:=0;
     for i:=1 to n do
     begin
     read(x);
     inc(s,x);
     end;
     rez:=0;
     for i:=1 to 5 do
     begin
       if ((s+i)mod (n+1))<>1
       then inc(rez);
     end;
     writeln(rez);
end.


var s : string;
    i,p,k,kk,m,v,j,min,n : longint;
    ss : array [1..100] of string;
    a : array [1..100] of longint;
procedure qsort(l,r : longint);
var w,q : longint;
    ww : string;
begin
   i:=l; j:=r;
   q:=a[(l+r) div 2];
   while i<=j do
      begin
      while a[i]<q do inc(i);
      while a[j]>q do dec(j);
      if i<=j then
         begin
         w:=a[i]; a[i]:=a[j]; a[j]:=w;
         ww:=ss[i]; ss[i]:=ss[j]; ss[j]:=ww;
         inc(i); dec(j);
         end;
      end;
   if l<j then qsort(l,j);
   if i<r then qsort(i,r);
end;
begin
   min:=1000000000;
   readln(s);
   p:=1;
   for i:=1 to length(s) do
      begin
      if s[i]=' ' then
        begin
        inc(n);
        ss[n]:=copy(s,p,i-p);
        p:=i+1;
        end;
      if i=length(s) then
         begin
         inc(n);
         ss[n]:=copy(s,p,i-p+1);
         end;
      end;
   for i:=1 to n do
      begin
      val(ss[i][1],v,m);
      a[i]:=v;
      end;
   qsort(1,n);
   //koutsu
   for i:=1 to n do
      begin
      kk:=0;
      for j:=i to n do
         if ss[i]=ss[j] then inc(kk);
      if kk>2 then min:=0;
      if (kk=1) and (2<min) then min:=2;
      if (kk=2) and (1<min) then min:=1;
      kk:=0;
      for j:=i to n do
         begin
         if (a[j]-a[i]=1) and (ss[i][2]=ss[j][2]) and (k=0) then
            begin
            inc(kk);
            inc(k);
            end;
         if (a[j]-a[i]>2) and (ss[i][2]=ss[j][2]) then break;
         if (a[j]-a[i]=2) and (ss[i][2]=ss[j][2]) then
            begin
            inc(kk);
            break;
            end;
         end;
      k:=0;
      if (kk=0) and (2<min) then min:=2;
      if (kk=1) and (1<min) then min:=1;
      if kk>1 then min:=0;
      end;
   writeln(min);
end.


Program p;
var x, k: integer;
    l: array [0..1] of integer;
    s: string;

begin
read(l[0], l[1], x);
l[0]+=-1;
k:=1;
s:='0';
while x>1 do
  begin
  s+=inttostr(k);
  l[k]+=-1;
  k:=1-k;
  x:=x-1
  end;
if (l[0]=0) and (x=1) and (s[length(s)]='1') then
  for var g:=1 to l[1] do
    s:='1'+s
      else
      begin
k:=1-k;
for var g:=1 to l[k] do
  s+=inttostr(k);
k:=1-k;
for var g:=1 to l[k] do
  s+=inttostr(k);
end;
write(s)
end.


var ans,i,j:longint;
    s,t:string;
begin
  readln(s);
  t:='aeiou13579';
  for i:=1 to length(s) do
    for j:=1 to length(t) do
    if s[i]=t[j] then
    begin
      inc(ans);
      break;
    end;
  writeln(ans);
end.


var n,k:int64;
begin readln(n,k);
if (n div k) mod 2 <>0 then write('YES')
else write('NO')
end.


program n1;
const nmax=200;

var a: array [0..nmax] of char;
	i, j, n, k, kk,  p, ans, koln, kolmax: integer;
	yes: boolean;
begin
	yes:= false;
	read(n);
	read(k);
        readln;
	for i:=1 to n do
		read(a[i]);
	a[0]:='Y';
	a[n+1]:='Y';
	ans := 0;
	for i:=1 to n do
		if a[i]='N' then begin
			koln:=1;
			j:=i+1;
			while a[j]='N' do begin
				j:=j+1;
				koln:=koln+1
			end;
			if koln > kolmax then kolmax:=koln;
		end;
	if kolmax > k then write('NO')
	else begin
	    for i:=0 to n do begin
	        for j:= i + 1 to n + 1 do begin
	            if ((a[i] = '?') or (a[i] = 'Y')) and ((a[j] = '?') or (a[j] = 'Y')) then begin
                    p := 0;
	                for kk:= i + 1 to j - 1 do begin
	                    if a[kk] = 'Y' then p := 1;
	                end;
	                if (p = 0) and (j - i = k + 1) then begin
	                    ans := 1;
                end;
            end;
        end;
    end;
    if ans = 1 then writeln('YES')
    else writeln('NO')
	end
end.


var i,n,m,t,w,s:longint;
a:array[1..100000] of longint;
function max(x,y:longint):longint;
begin
if x>y then exit(x);
exit(y);
end;
begin
//assign(input,'cdhxzzf.in');reset(input);
//assign(output,'cdhxzzf.out');rewrite(output);
readln(n,m);
for i:=1 to n do read(a[i]);
for i:=0 to max(m-1,n-m) do
  begin
  t:=m-i;w:=m+i;
  if (t>=1)and(w<=n) then
    begin
    if (a[t]=1)and(a[w]=1) then
      begin
      if i<>0 then s:=s+2
      else s:=s+1;
      end
    end
  else
    if (t>=1)and(w>n) then
      begin
      if a[t]=1 then inc(s);
      end
    else
    if (w<=n)and(t<1) then
      begin
      if a[w]=1 then inc(s);
      end;
  end;
writeln(s);
close(input);
close(output);
end.


const
  HR=1000000007;
var
   n,m:qword;
   k:longint;
function pow(a,b,n:qword):qword;
var t,y:qword;
begin
  t:=1;
  y:=a;
  while b<>0 do
  begin
    if b and 1=1 then t:=t*y mod n;
    y:=y*y mod n;
    b:=b>>1;
  end;
  exit(t);
end;
begin
  read(n,m,k);
  if ((n+m) mod 2=1)and(k=-1) then
  begin
    writeln(0);
    exit;
  end;
  dec(n);
  dec(m);
  n:=n mod (HR-1);
  m:=m mod (HR-1);
  writeln(pow(2,n*m,HR));
end.


Program Madalina;
var n,i,j,p1,p2:longint;
    t:array[0..105] of longint;
begin
        readln(n);
        for i:=1 to n do read(t[i]);
        for i:=1 to n do
                 begin
                 read(j);
                 if (t[i]=1) and (j=0) then inc(p1);
                 if (t[i]=0) and (j=1) then inc(p2);
                 end;
        if (p1=0) then writeln(-1) else
                begin
                writeln((p2 div p1)+1);
                end;
end.


var n,i,j,k,t,ma,ans,m:longint;
  a,dp:array[0..10000] of longint;
  js:array[0..300] of longint;
function max(a,b:longint):longint;
begin
  if a>b then exit(a) else exit(b);
end;
function min(a,b:longint):longint;
begin
  if a<b then exit(a) else exit(b);
end;
begin
  readln(n,t);
  fillchar(js,sizeof(js),0);
  ma:=0;
  for i:=1 to n do begin read(a[i]);inc(js[a[i]]);end;

  for i:=1 to 300 do if js[i]>ma then ma:=js[i];
  ans:=ma*t;
  m:=min(n,t);
  for i:=n+1 to m*n do a[i]:=a[i-n];

  for i:=1 to m*n do
    begin
      dp[i]:=1;
      for j:=max(1,i-n) to i-1 do if a[i]>=a[j] then dp[i]:=max(dp[i],dp[j]+1);
      ans:=max(ans,dp[i]+ma*(t-m));
    end;
  writeln(ans);
end.


var s,x,i:integer;
begin
  for i:=1 to readlninteger do begin
    readln(s); var ans:='';
    for x:=9 downto 1 do begin
      if s>=x then begin
          ans:=chr(48+x)+ans; s-=x
      end else begin
          ans:=chr(48+s)+ans; s:=0
      end;
      if s=0 then break
    end;
    println(ans)
  end
end.


program cf314B;
var
t1,t2,now,j,tot,i:longint;
x1,x2:ansistring;
c,d:array[0..100000] of longint;
f:array['a'..'z'] of boolean;
begin
readln(t1,t2);
readln(x1);
readln(x2);
now:=1;
for i:=1 to length(x1) do f[x1[i]]:=true;
for i:=1 to length(x2) do if not f[x2[i]] then begin writeln(0);halt;end;
fillchar(c,sizeof(c),0);
tot:=0;
i:=0;
while i<t1 do begin
inc(i);
for j:=1 to length(x1) do
begin
if x1[j]=x2[now] then
inc(now);
if now>length(x2) then begin
now:=1;
if c[j]=0 then  begin c[j]:=i;inc(tot);d[j]:=tot;end else begin
now:=1;
//d:=i-c[j];
inc(tot);
tot:=tot+(tot-d[j])*((t1-i) div (i-c[j]));
i:=t1-(t1-i) mod (i-c[j]);
fillchar(c,sizeof(c),0);;
end;
end;
end;
end;
writeln(tot div t2);
end.


var
   n,v,i,k,a,j:integer;
begin
     read(n,v);
     a:=1;
     for i:=1 to n do
     begin
          a:=a-1;
          if a=n-i then break;
          k:=a;
          repeat
                a:=a+1;
          until (a=v) or (a=n-i);
          j:=j+((a-k)*i);
     end;
     write(j);
end.


uses math;
var a:array[1..2,0..100] of longint;
        b:array[1..100] of longint;
        i,j,k,l,m,n,z:longint;
begin
readln(n,k);
for i:=1 to n do
read(b[i]);
for i:=1 to n do
inc(a[b[i],i mod k]);
z:=0;
for i:=0 to k-1 do
z:=z+min(a[1,i],a[2,i]);
writeln(z);
end.


Uses math;
Var fi, fo: text;
    l1, l2, r1, r2, k, a, b: int64;

Begin
	assign(fi,''); reset(fi);
	assign(fo,''); rewrite(fo);
	readln(fi, l1, r1, l2, r2, k);
	if (L1<=L2) then
	begin
		if (R1>=L2) and (R1<=R2) then
		begin
			a:= L2;
			b:= R1;
		end;
		if R1>=R2 then
		begin
			a:= L2;
			b:= R2;
		end;
	end;
	if (L1>L2) and (L1<=R2) then
	begin
		if R1<=R2 then
		begin
			a:= L1;
			b:= R1;
		end;
		if R1>=R2 then
		begin
			a:= L1;
			b:= R2;
		end;
	end;
	if (a<>0) and (b<>0) then
		if (k>=a) and (k<=b) then writeln(fo, b-a)
		else writeln(fo, b-a+1)
	else writeln(fo, 0);
	close(fi); close(fo);
End.


program LH;
var
   i,n,m,ans:longint;
begin
   readln(n,m);ans:=0;
   for i:=0 to trunc(sqrt(n)) do
   if (i+(n-i*i)*(n-i*i)=m) then inc(ans);
   writeln(ans);
end.


var min,n,a,b,c:int64;
        ii,jj,kk,pp:longint;
        i,j,k:int64;
begin
        readln(n,a,b,c);
        min:=a*10;
        for ii:=0 to 10 do
                for jj:=0 to 10 do
                        for kk:=0 to 10 do
                        begin
                                i:=ii;
                                j:=jj;
                                k:=kk;
                                if (i+j*2+k*3 + n ) mod 4=0 then
                                if i*a+b*j+k*c < min then min:=i*a+b*j+k*c;
                        end;
                writeln(min);

end.


const
        fi='';
        fo='';
        maxn=1000100;
        maxc=1000000000;
        mm=1000000000+7;
var
        d,f,inn:array[0..2*maxn] of int64;
        n:longint;
        res:int64;
{-------------------------}
procedure openfiles;
begin
        assign(input,fi);
        reset(input);
        assign(output,fo);
        rewrite(output);
end;
{------------------------}
procedure closefiles;
begin
        close(input);
        close(output);
end;
{-------------------------}
procedure nhap;
begin
        read(n);
end;
{--------------------------}
function inv(x:longint):int64;
var
        m,n,xm,xn,xr,q,r:int64;
begin
        m:=x; n:=mm;
        xm:=1; xn:=0;
        while n<>0 do
        begin
                q:=m div n;
                r:=m-q*n;
                xr:=xm-q*xn;
                m:=n; xm:=xn;
                n:=r; xn:=xr;
        end;
        exit(xm);
end;
{--------------------------}
procedure xuly;
var
        i,j:longint;
        tmp:int64;
begin
        f[1]:=1;
        d[0]:=1;
        d[n]:=1;
        for i:=n+1 to 2*n do
        begin
                tmp:=inv(i-n);
                d[i]:=(d[i-1]+((n*d[i-1])mod mm)*tmp)  mod mm;
        end;
        for i:=2 to 2*n do
        begin
                f[i]:=(2*f[i-1]-d[i-1]+mm) mod mm;
        end;

        for i:=1 to 2*n do res:=(res+2*f[i]) mod mm;
        writeln((res+1) mod mm);
end;
{-------------------------}
BEGIN
        openfiles;
        nhap;
        xuly;
        closefiles;
END.


var a,b:array [1..10000] of integer;
c,d,e:integer;
I, k, j: integer;
begin
readln (c,d,e);
I:=1;
a[c]:=1;
b[d]:=1;
while (c<=e) do
begin
c:=round((c/i));
I:=I+1;
c:=c*i;
if (c<=e) then begin a[c]:=1; end;
end;

I:=1;

while (d<=e) do
begin
d:=round((d/i));
I:=I+1;
d:=d*i;
if (d<=e) then begin b[d]:=1; end;
end;
k:=0;
for j:=1 to round(e) do begin
if ((a[j]=1) and (b[j]=1)) then k:=k+1;
end;
writeln(k);
end.


var n,m:int64;
Function GTN(a,x:int64):int64;
var tmp:int64;
begin
        if x=0 then GTN:=1
        else begin
                tmp:=sqr(GTN(a,x div 2)) mod 1000000007;
                if (x mod 2)=1 then tmp:=tmp*a mod 1000000007;
                GTN:=tmp;
        end;
end;
Function GTN2(x:int64):int64;
var tmp:int64;
begin
        if x=0 then GTN2:=1
        else begin
                tmp:=sqr(GTN2(x div 2)) mod 1000000007;
                if (x mod 2)=1 then tmp:=tmp*2 mod 1000000007;
                GTN2:=tmp;
        end;
end;
begin
        read(n,m);
        writeln((GTN(GTN2(m)-1,n)) mod 1000000007);
end.


{$R+,Q+,I+}
{$apptype console}
Uses SysUtils,math;
Var
   n,m,x,y,a,b,k,a1,b1,x1,y1,x2,y2,x3,y3,x4,y4,r,ans1,ans2,ans3,ans4,r1,m1:Int64;
   i,j:Integer;
Function Gcd(a,b:Int64):Int64;
Begin
   If b=0 Then Gcd:=a
          Else Gcd:=Gcd(b,a mod b);
End;
Function Check(x1,x2,x3,x4,y1,y2,y3,y4:Int64):Boolean;
Begin
   Check:=(x1<y1) or ((x1=y1) and (x2<y2)) or ((x1=y1) and (x2=y2) and (x3<y3)) or ((x1=y1) and (x2=y2) and (x3=y3) and (x4<y4));
End;
Begin
   Read(n,m,x,y,a,b);
   r:=Gcd(a,b);
   a:=a div r;
   b:=b div r;
   k:=min(n div a,m div b);
   a1:=k*a;
   b1:=k*b;
   x1:=Round(x-a1/2);
   y1:=Round(y-b1/2);
   x2:=x1+a1;
   y2:=y1+b1;
   If x1<0 Then Begin
      x2:=x2-x1;
      x1:=0;
   End;
   If y1<0 Then Begin
      y2:=y2-y1;
      y1:=0;
   End;
   If x2>n Then Begin
      x1:=x1-x2+n;
      x2:=n;
   End;
   If y2>m Then Begin
      y1:=y1-y2+m;
      y2:=m;
   End;
   m1:=High(Int64);
   ans1:=0;
   ans2:=0;
   ans3:=0;
   ans4:=0;
   For i:=-100 To 100 Do
      For j:=-100 To 100 Do Begin
         x3:=x1+int64(i);
         y3:=y1+int64(j);
         x4:=x3+a1;
         y4:=y3+b1;
         If (x3>=0) and (x4<=n) and (y3>=0) and (y4<=m) Then Begin
            r1:=((x3+x4)-2*x)*((x3+x4)-2*x)+((y3+y4)-2*y)*((y3+y4)-2*y);
            If r1<m1 Then Begin
               m1:=r1;
               ans1:=x3;
               ans2:=y3;
               ans3:=x4;
               ans4:=y4;
            End
            Else If (r1=m1) and (Check(x3,y3,x4,y4,ans1,ans2,ans3,ans4)) Then Begin
               ans1:=x3;
               ans2:=y3;
               ans3:=x4;
               ans4:=y4;
            End;
         End;
      End;
   Write(ans1,' ',ans2,' ',ans3,' ',ans4);
End.


var i,j,k,l,m,n:longint;
    a:Array[0..30] of longint;
    f:array[0..30] of boolean;

procedure swap(var a,b:longint);
var t:longint;
begin
    t:=a;a:=b;b:=t;
end;

procedure print;
begin
    writeln('NO');
    halt;
end;

begin
    read(n);
    for i:=1 to n do read(a[i]);
    for i:=1 to n-1 do
        for j:=i+1 to n do if a[j]<a[i] then swap(a[i],a[j]);
    for i:=1 to n do
    begin
        k:=1;
        j:=i;
        while (k<a[i])and(j<>0) do
        begin
            if (not f[j])and(a[j]<=a[i]-2)and(k+a[j]<=a[i]) then
            begin
                k:=k+a[j];
                f[j]:=true;
            end;
            dec(j);
        end;
        if j<0 then print;
    end;
    for i:=1 to n-1 do if not f[i] then print;
    writeln('YES');
end.


program zB;

{$APPTYPE CONSOLE}
uses
  SysUtils, math;

var i,n,d1,d2,x1,x2,y,j,f1,f2:longint;
    a:array[1..100] of LongInt;

begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }
readln(n);
for i:=1 to n do read(a[i]);

i:=1;
while a[i]=a[i+1] do Inc(i);

if (i=n) or (n=1) then Writeln(0)
else
begin
d1:=Abs(a[i] - a[i+1]);
if (a[i] + a[i+1]) mod 2 = 0 then
 d2:=Abs(a[i] - ((a[i] + a[i+1]) div 2))
  else d2:=-1;

    //d1
x1:=a[i];
x2:=a[i+1];

y:= (a[i] + a[i+1]) div 2;
j:=i;
while i<=n do
 begin
   if not((a[i] = x1) or (a[i] + d1 = x1) or (a[i] - d1 = x1) ) then
      begin
      f1:=-1;
      Break;
      end;
 inc(i);
 end;
i:=j;
while i<=n do
 begin
   if not((a[i] = x2) or (a[i] + d1 = x2) or (a[i] - d1 = x2)) then
      begin
      f2:=-1;
      Break;
      end;
 inc(i);
 end;

if (f1=-1) and (f2=-1) then d1:=-1;

    //d2
i:=j;
while (i<=n) and (d2<>-1) do
 begin
   if not((a[i] = y) or (a[i] + d2 = y) or (a[i] - d2 = y)) then
      begin
      d2:=-1;
      Break;
      end;
 inc(i);
 end;

if Min(d1,d2)<>-1 then writeln(Min(d1,d2))
else
if Max(d1,d2)<>-1 then writeln(Max(d1,d2))
else Writeln(-1);

end;

{Writeln(d1,' ',d2);
close(input);
close(output); }
end.


var n,i:longint;
    s:ansistring;
    d:array['a'..'z'] of longint;
begin
        readln(n);
        read(s);
        if n=1 then
        begin
                write('YES');
                halt;
        end;
        for i:=1 to n do inc(d[s[i]]);
        for i:=1 to n do
        begin
                if d[s[i]]>=2 then
                begin
                        write('YES');
                        halt;
                end;
        end;
        write('NO');
end.


type swap = record
s:longint;
d:longint;
End;

var f1,f2:text;
n,res,i,spt,sl,top:longint;
A,Count:array[0..20] of longint;
KQ:array[1..1 shl 20] of swap;

Procedure chuyen(s,d:longint);
Begin
        inc(res);
        KQ[res].s:=s;
        KQ[res].d:=d;
End;

Procedure U(s,d,tg,vt:longint);
var i:longint;
begin
        if vt>spt then exit;
        U(s,tg,d,vt+1);
        for i:=1 to count[vt] do chuyen(s,d);
        U(tg,d,s,vt+1);
End;

Procedure C(s,d,tg,vt:longint);
var i:longint;
Begin
        if vt>spt then exit;
        if vt=spt then
        Begin
          for i:=1 to count[vt]-1 do chuyen(s,tg);
          chuyen(s,d);
          for i:=1 to count[vt]-1 do chuyen(tg,d);
          Exit;
        End;
        if count[vt]=1 then
        Begin
          U(s,d,tg,vt);
          Exit;
        End;
        U(s,d,tg,vt+1);
        for i:=1 to count[vt] do chuyen(s,tg);
        U(d,s,tg,vt+1);
        for i:=1 to count[vt] do chuyen(tg,d);
        C(s,d,tg,vt+1);
End;

Begin
        assign(f1,'');reset(f1);
        assign(f2,'');rewrite(f2);
        readln(f1,n);
        For i:=1 to n do
        Begin
        read(f1,A[i]);
        if A[i]<>A[i-1] then inc(spt);
        Inc(Count[spt]);
        End;
        C(1,3,2,1);
        Writeln(f2,res);
        for i:=1 to res do
        writeln(f2,KQ[i].s,' ',KQ[i].d);

        close(f1);
        close(f2);
End.


uses math;

type my = record
  x,y:int64;
  end;

type my2 = record
  x,y:int64;
  end;

var a,b:array[0..200000] of my;
    c,d:array[0..200000] of my2;
    i,n,m:longint;
    l,r,mid,j:longint;
    mx,dd,d1:int64;

 procedure sort(l,r: longint);
      var
         i,j: longint;
         x,y:my;
      begin
         i:=l;
         j:=r;
         x:=a[l+random(r-l)];
         repeat
           while (a[i].x>x.x)or((a[i].x=x.x)and(a[i].y<x.y)) do
            inc(i);
           while (x.x>a[j].x)or((x.x=a[j].x)and(x.y<a[j].y)) do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

       procedure sort1(l,r: longint);
      var
         i,j: longint;
         x,y:my;
      begin
         i:=l;
         j:=r;
         x:=b[l + random(r-l)];
         repeat
              while (b[i].x>x.x)or((b[i].x=x.x)and(b[i].y<x.y)) do
            inc(i);
           while (x.x>b[j].x)or((x.x=b[j].x)and(x.y<b[j].y)) do

   dec(j);
           if not(i>j) then
             begin
                y:=b[i];
                b[i]:=b[j];
                b[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort1(l,j);
         if i<r then
           sort1(i,r);
      end;

 begin

// assign(input,'input.txt'); reset(input);
// assign(output,'output.txt'); rewrite(output);

  read(n,m,dd);
  for i := 1 to n do read(a[i].x,a[i].y);
  for i := 1 to m do read(b[i].x,b[i].y);

  sort(1,n);
  sort1(1,m);

 // for i := 1 to n do writeln(a[i].x,' ',a[i].y);
 // writeln();
 // for i := 1 to m do writeln(b[i].x,' ',b[i].y);

  for i :=1 to n do
   begin
    c[i].x:=c[i-1].x + a[i].x;

    c[i].y:=c[i-1].y + a[i].y;

   end;

  for i :=1 to m do
   begin
    d[i].x:=d[i-1].x + b[i].x;

    d[i].y:=d[i-1].y + b[i].y;

   end;

  for i:= 1 to n do
   begin
    if(c[i].y>dd) then break;
    d1:=dd - c[i].y;
    l:=1;
    r:=m;
    while(l+1<r) do
     begin
      mid:=(l+r) >> 1;
      if(d[mid].y>d1) then r:=mid else l:=mid;
     end;
     for j := min(m,r+5) downto max(1,l-5) do
      begin
     if(d[j].y<=d1) then
      begin
       mx:=max(mx,c[i].x + d[j].x);
       break;
      end;
      end;
   end;

   writeln(mx);

 end.


var n,m,k,i,min,j:integer;
    a,b,c:array[1..100] of integer;
begin
  j:=0;
  readln(n,m,k);
  for i:=1 to n do
  read(a[i]);

  for i:=1 to n do
  if (a[i]<=k) and (a[i]<>0) then b[i]:=i;

  for i :=1 to n do
   if b[i]<>0 then
   min:=abs(b[i]-m);

  for i:=1 to n do
  if b[i]<>0 then
  if abs(b[i]-m)<=min then min:=abs(b[i]-m);
  writeln(min*10);

end.


var x,i,j:longint;
begin
        readln(x);
        for i:=1 to x do
                for j:=1 to x do
                        begin
                                if (i mod j=0) and (i*j>x) and ((i/j)<x) then
                                        begin
                                                writeln(i,' ',j);
                                                halt;
                                        end;
                        end;
        writeln(-1);
end.


{$r-,q-,s-,i-,o+}
var
  dx,dy,d,a1,a2,b1,b2,c1,c2,xa,ya,xb,yb,xc,yc:int64;

  procedure check(xd,yd:int64);
    begin
      a1:=xc;b1:=-yc;c1:=xd;
      a2:=yc;b2:=xc;c2:=yd;
      if (a1=0)and(b1=0)and(c1<>0)then exit;
      if (a2=0)and(b2=0)and(c2<>0)then exit;
      d:=a1*b2-b1*a2;
      dx:=a1*c2-c1*a2;
      dy:=c1*b2-b1*c2;
      if (d=0)and(dx=0)and(dy=0)then begin
        writeln('YES');
        halt(0);
      end;
      if (d=0)then exit;
      if (dx mod d=0)and(dy mod d=0)then begin
        writeln('YES');
        halt(0);
      end;
    end;

begin
  read(xa,ya);
  read(xb,yb);
  read(xc,yc);
  check(xb-xa,yb-ya);
  check(xb+xa,yb+ya);
  check(xb+ya,yb-xa);
  check(xb-ya,yb+xa);
  writeln('NO');
end.


program task_e;
uses math,sysutils;
const
  ans:array[0..2]of string=('Stas','Masha','Missing');
var
  n:extended;
  a,b,k:integer;
function wining(a,b:integer):boolean;
begin
  if b>k then begin writeln(ans[2]); halt; end;
  if intpower(a,b)>=n then result:=true
    else if (b>1)or(a=1)
      then result:=not(wining(a+1,b)and wining(a,b+1))
      else result:=not(wining(a,b+1)and wining(a+1,b));
end;
begin
{  reset(input,'test.in');
  rewrite(output,'test.out');
}
try
  read(a,b,n);
  k:=ceil(logn(2,n))+1;
  writeln(ans[ord(wining(a,b))])
except
  writeln(ans[0]);
  halt;
end;
end.


var i,k,n:byte; l:integer;
    a:array[1..5] of integer;
begin
readln(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
for k:=1 to n-i do
if a[k]>a[k+1] then
begin
l:=a[k];
a[k]:=a[k+1];
a[k+1]:=l;
end;
write(a[1+( n div 2)]);
readln;
end.


var
        bz:boolean;
        zx,zy,yx,yy:longint;
        zx1,zy1,yx1,yy1:longint;
        i,j,tot,a,b,ax,ay:longint;
        x1,y1,x2,y2:array[1..4] of longint;
function max(x,y:longint):longint;
begin
        if x>y then exit(x) else exit(y);
end;
function min(x,y:longint):longint;
begin
        if x<y then exit(x) else exit(y);
end;
procedure pd(a,b:longint);
begin
        if (a>=zx)and(a<=yx)and(b>=zy)and(b<=yy) then
        begin
                writeln('YES');
                halt;
        end;
end;
procedure swap(var a,b:longint);
var
        c:longint;
begin
        c:=a;
        a:=b;
        b:=c;
end;
begin
        //assign(input,'square.in');reset(input);
        //assign(output,'square.out');rewrite(output);
        read(x1[1],y1[1]);
        zx:=x1[1]; zy:=y1[1];
        yx:=x1[1]; yy:=y1[1];
        for i:=2 to 4 do
        begin
                read(x1[i],y1[i]);
                zx:=min(zx,x1[i]);
                zy:=min(zy,y1[i]);
                yx:=max(yx,x1[i]);
                yy:=max(yy,y1[i]);
        end;
        for i:=1 to 4 do read(x2[i],y2[i]);
        for i:=1 to 3 do
        begin
                for j:=i+1 to 4 do
                begin
                        if x2[i]>x2[j] then
                        begin
                                swap(x2[i],x2[j]);
                                swap(y2[i],y2[j]);
                        end;
                        if (x2[i]=x2[j])and(y2[i]>y2[j]) then
                        begin
                                swap(x2[i],x2[j]);
                                swap(y2[i],y2[j]);
                        end;
                end;
        end;
        a:=x2[1];
        b:=-1;
        while a<=x2[2] do
        begin
                inc(b);
                pd(a,y2[1]);
                for i:=1 to b do
                begin
                        pd(a,y2[1]+i);
                        pd(a,y2[1]-i);
                end;
                inc(a);
        end;
        while a<=x2[4] do
        begin
                dec(b);
                pd(a,y2[1]);
                for i:=1 to b do
                begin
                        pd(a,y2[1]+i);
                        pd(a,y2[1]-i);
                end;
                inc(a);
        end;
        writeln('NO');
end.


{$mode objfpc}
uses math;

var
  m,n,i:integer;
  f:array[0..1000000,0..4] of qword;
  kq:qword;

begin
  read(m,n);
  for i:=1 to max(m,n) do
    begin
      f[i]:=f[i-1];
      inc(f[i,i mod 5]);
    end;
  kq:=f[m,0]*f[n,0] + f[m,1]*f[n,4] + f[m,2]*f[n,3] + f[m,3]*f[n,2] + f[m,4]*f[n,1];
  write(kq);
end.


//fpc 3.0.0

program HelloWorld;
var n,i,j:integer;
a:array[1..3,1..6] of byte;

function can(h:integer):boolean;
var b:array[1..3] of byte;
used:array[1..3] of boolean;
i,y:integer;
bb:boolean;

procedure try1(m:integer);
var x,y:integer;
begin
    if m>3 then bb:=true else
    for y:=1 to 6 do
    for x:=1 to n do
    if not used[x] then
    if a[x,y]=b[m] then begin

        used[x]:=true;
        try1(m+1);
        used[x]:=false;
        end;

end;

begin
bb:=false;
 b[1]:=h div 100;
 b[2]:=(h div 10) mod 10;
 b[3]:=h mod 10;
  //  writeln(b[1],b[2],b[3]);

 y:=1;

 while b[y]=0 do inc(y);
 //writeln(y);
 for i:=1 to n do used[i]:=false;

 try1(y);
    can:=bb;
end;
begin
    readln(n);
    for i:=1 to n do
    for j:=1 to 6 do read(a[i,j]);

    i:=0;

    while can(i+1) and (i<1000) do inc(i);

    writeln(i);
end.


{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}
var
  ans,lg,rg,ca,cb,a,b,x1,y1,x2,y2,xa,ya,xb,yb: int64;

function up(x,y:int64):int64;
var
  u: int64;
begin
  u:=x div y;
  while (u-1)*y > x do dec(u);
  while u*y <= x do inc(u);
  up:=u;
end;

function down(x,y:int64):int64;
var
  u: int64;
begin
  u:=x div y;
  while u*y >= x do dec(u);
  while (u+1)*y < x do inc(u);
  down:=u;
end;

begin
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  read(a,b,x1,y1,x2,y2);
  xa:=x1+y1; ya:=x1-y1;
  xb:=x2+y2; yb:=x2-y2;
  if (a = 1) or (b = 1) then ans:=(abs(x1-x2)+abs(y1-y2)) div 2 else
  begin
    if xa < xb then
    begin
      lg:=up(xa,2*a);
      rg:=down(xb,2*a);
    end else
    begin
      lg:=up(xb,2*a);
      rg:=down(xa,2*a);
    end;
    ca:=rg-lg+1;
    if ya < yb then
    begin
      lg:=up(ya,2*b);
      rg:=down(yb,2*b);
    end else
    begin
      lg:=up(yb,2*b);
      rg:=down(ya,2*b);
    end;
    cb:=rg-lg+1;
    if ca > cb then ans:=ca
    else ans:=cb;
  end;
  writeln(ans);
  close(input);
  close(output);
end.


var a,b:array[1..100000] of int64;
    x,n,w,q,m,k,o,p,e,max:int64;
    i,j:longint ;
    s,g:string;
begin
//assign(input,'input.txt');
//reset(input);
//assign(output,'output.txt');
//rewrite(output);
read(x,n,w,q);

if x>n then write('First')
else write('Second');
end.


var n,i:longint;
    m,tot:int64;
    a:array[1..50]of longint;
    f:array[1..50,false..true,false..true]of int64;
    p:array[1..50,false..true,false..true]of boolean;
function hs(l:longint;p1,p2:boolean):int64;
var x,y,r:longint;
begin
  r:=n-l+1;
  if l>r then begin hs:=1;exit;end;
  if p[l,p1,p2] then begin hs:=f[l,p1,p2];exit;end;
  p[l,p1,p2]:=true;
  for x:=0 to 1 do if (a[l]=-1)or(a[l]=x) then
  for y:=0 to 1 do if (a[r]=-1)or(a[r]=y) then
  if ((l<r)or(x=y))and((x<=y)or(p1))and((x<=1-y)or(p2)) then
  f[l,p1,p2]:=f[l,p1,p2]+hs(l+1,p1 or (x<y),p2 or (x<1-y));
  hs:=f[l,p1,p2];
end;
begin
  read(n,m);inc(m);
  for i:=1 to n do a[i]:=-1;
  if hs(1,false,false)<m then
  begin
    writeln(-1);exit;
  end;
  for i:=1 to n do
  begin
    fillchar(f,sizeof(f),0);fillchar(p,sizeof(p),0);
    a[i]:=0;tot:=hs(1,false,false);
    if tot<m then
    begin
      m:=m-tot;a[i]:=1;
    end;
  end;
  for i:=1 to n do write(a[i]);writeln;
end.


var n,i:longint;
begin
 readln(n);
 write(n);
 i:=1;
 repeat
  inc (i);
  if n mod i=0 then
   begin
    n:=n div i;
    write(' ',n);
    i:=1;
   end;
 until n=1;
end.


var n:longint;
begin
  readln(n);
  writeln((n+1) div 2);
end.


var a,b,c,x,y,z,i,j,n,m,q:longint;
s,v:string;
 begin
  readln(n);
  readln(S);
   for i:=1 to n do
    begin
     if s[i]='X' then inc(x) else inc(y);
    end;
    if (x=n div 2) and (y=n div 2) then
     begin
      writeln(0);
       for i:=1 to n do write(s[i]);
     end else
     if x>y then
      begin
       writeln(x-(n div 2));
       for i:=1 to n do
        begin
        if x>y then
         begin
          if s[i]='X' then begin write('x'); dec(X); inc(y);  end else write(s[i]);
         end else write(s[i]);
        end
        end else
        if x<y then
      begin
       writeln(y-(n div 2));
       for i:=1 to n do
        begin
        if x<y then
         begin
          if s[i]='x' then begin write('X'); dec(y); inc(x); end else write(s[i]);
         end else write(s[i]);
        end;
      end;
 end.


var s:string;
cur,p:longint;
begin
read(s);
cur:=1;
p:=length(s);
while (cur<p-1) do begin
if (s[cur]='/') and (s[cur+1]='/')then begin
Delete(s,cur,1);
dec(cur);
end;
p:=length(s);
inc(cur);
end;
if (length(s)>1) and (s[length(s)-1]='/') and (s[length(s)]='/')then Delete(s,length(s)-1,1);
if (s[length(s)]='/') and (length(s)>1) then Delete(s,length(s),1);
writeln(s);
end.


var a,b,c,d,e,x:longint;
begin
 readln(x);
 a:=x div 5;
 x:=x-(5*a);
 b:=x div 4;
 x:=x-(4*b);
 c:=x div 3;
 x:=x-(3*c);
 d:=x div 2;
 x:=x-(2*d);
 e:=x+a+b+c+d;
 writeln(e);
end.


program B223;
const
    inp='';
    oup='';
    max=7000;
var
    F,Fo:text;
    StackL,StackR,StackV,StackT:array[1..max] of longint;
    DD:array[0..1000000] of longint;
    Cx:array[0..1000000] of longint;
    LeftC,RightC:array[1..max] of longint;
    Top:longint;
    Number,N,M:longint;
(*      *)
procedure Init;
var i,s:longint;
begin
    S:=1;
    DD[1]:=1;
    for i:=1 to 18 do
        begin
            s:=s*2;
            DD[s]:=1;
        end;
    for i:=2 to 1000000 do DD[i]:=DD[i-1]+DD[i];
end;
(*      *)
procedure Push(T,L,R,V:longint);
begin
    inc(Top);
    StackT[Top]:=T;
    StackL[Top]:=L;
    StackR[Top]:=R;
    StackV[Top]:=V;
end;
(*      *)
function Intersec(L1,R1,L2,R2:longint):boolean;
var res:boolean;
begin
    res:=false;
    res:=res or ((L1<=L2) and (R1>=L2));
    res:=res or ((L2<=L1) and (R2>=L1));
    exit(res);
end;
(*      *)
function Ans(T,V:longint):longint;
var i,curL,curR,res:longint;
begin
    for i:=1 to N do
        begin
            LeftC[i]:=0;
            RightC[i]:=0;
        end;
    LeftC[T]:=V; RightC[T]:=V;
    for i:=T+1 to N do
        begin
            curL:=LeftC[i-1];
            curR:=RightC[i-1];
            curL:=(curL-1)+DD[curL-1]+1;
            if DD[curR]=DD[curR-1]+1 then
                begin
                    curR:=(curR-1)+DD[curR-1]+2;
                end
            else
                begin
                    curR:=(curR-1)+DD[curR-1]+1;
                end;
            LeftC[i]:=CurL;
            RightC[i]:=CurR;
        end;
    res:=0;
    inc(number);
    for i:=1 to Top do if StackT[i]>=T then
        begin
            if Intersec(LeftC[StackT[i]],RightC[StackT[i]],StackL[i],StackR[i]) then
                begin
                    if Cx[StackV[i]]<>number then inc(res);
                    Cx[StackV[i]]:=number;
                end;
        end;
    exit(res);
end;
(*      *)
procedure Nhap;
var i:longint;
    cases:longint;
    t,l,r,v:longint;
begin
    assign(f,inp);  reset(f);
    assign(fo,oup);  rewrite(fo);
    readln(f,N,M);
    init;
    for i:=1 to M do
        begin
            read(f,cases);
            case cases of
                1:
                    begin
                        readln(f,t,l,r,v);
                        push(t,l,r,v);
                    end;
                2:
                    begin
                        readln(f,t,v);
                        writeln(fo,Ans(t,v));
                    end;
            end;
        end;
    close(f);
    close(fo);
end;
(*      *)
BEGIN
    nhap;
END.


{$mode objfpc}
program a214;
const
  fin = '';
  fout = '';
var
  s: integer;
  i, j, k: integer;
  a, b: array [1..4, 1..2] of integer;

begin
  assign(input, fin); reset(input);
  assign(output, fout); rewrite(output);
  readln(s);
  for i := 1 to 4 do
    begin
      for j := 1 to 2 do
        read(a[i][j]);
      for j := 1 to 2 do
        read(b[i][j]);
    end;
  for i := 1 to 4 do
    for j := 1 to 2 do
      for k := 1 to 2 do
        if a[i][j] + b[i][k] <= s then
          begin
            writeln(i,' ',a[i][j],' ',s - a[i][j]);
            halt;
          end;
  writeln(-1);
  close(input);
  close(output);
end.


program solution;

{$APPTYPE CONSOLE}
{$R+,Q+}

uses
	SysUtils, Math;

const a : array[0..29] of integer = (0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12);

var
  p : array[1..40000] of boolean;
  q, k, i, t, n, ans : integer;
  j : int64;
  s : array[1..29] of integer;

begin
	{$IFNDEF ONLINE_JUDGE}
		reset(input, 'input.txt');
		rewrite(output, 'output.txt');
	{$ENDIF}
  read(n);
  i := 2;
  s[1] := 1;
  t := floor(sqrt(n));
  q := 0;
  while i <= t do begin
    if p[i] then begin
      inc(i);
      continue;
    end;
    j := i;
    k := 0;
    while j <= n do begin
      if j <= t then
        p[j] := true else
        inc(q);
      inc(k);
      j := j * i;
    end;
    inc(s[k]);
    inc(i);
  end;
  inc(s[1], n - t - q);
  for i := 1 to 29 do
    if odd(s[i]) then
      s[i] := 1 else
      s[i] := 0;
  ans := 0;
  for i := 1 to 29 do begin
    ans := ans xor a[s[i] * i];
  end;
  if ans <> 0 then
    write('Vasya') else
    write('Petya');

end.


var
  s : string;
  nom,i,j,k,max : longint;
begin
  readln(s);
  max:=-2;
  for i:=length(s) downto 1 do
   begin
     for j:=length(s) downto i+1 do
      inc(k,ord('9')-ord(s[j]));
     dec(k);
     if max<k
       then begin
              max:=k;
              nom:=i;
            end;
     k:=0;
   end;
  if (max<=0)
    then begin
           writeln(s);
           halt;
         end;
  for i:=1 to nom-1 do
   begin
     write(s[i]);
   end;
  s[nom]:=chr(ord(s[nom])-1);
  if (nom<>1) or
     (s[nom]<>'0')
    then write(s[nom]);
  for i:=nom+1 to length(s) do
   write('9');
end.


var
dd:int64;
used:Array[0..4000000]of boolean;
n,l,r,p,i,fir,sec,ans:longint;
t:longint;
f:array[0..1000]of int64;
d,a:array[0..4000000]of longint;
function prost(x:longint):boolean;
var i:longint;
begin
  for i:=2 to round(sqrt(x)) do
   if x mod i=0 then
    begin
     prost:=false;
     exit;
    end;
  prost:=true;
end;
procedure go(x,d:longint);
begin
   if d>t then
    begin
     inc(n);
     a[n]:=x;
     exit;
    end;
   go(x,d+1);
   if int64(x)*f[d]<=r then go(x*f[d],d);
end;
procedure sort(l,r:longint);
var i,j,x,u:longint;
begin
 i:=l;
 j:=r;
 x:=a[l+random(r-l)];
 while i<=j do
  begin
   while x>a[i] do inc(i);
   while x<a[j] do dec(j);
   if i<=j then
    begin
     u:=a[i];
     a[i]:=a[j];
     a[j]:=u;
     inc(i);
     dec(j);
    end;
  end;
 if l<j then sort(l,j);
 if i<r then sort(i,r);
end;
 begin
  readln(l,r,p);
  for i:=2 to p do
   if prost(i) then
    begin
      inc(t);
      f[t]:=i;
    end;
  go(1,1);
  sort(1,n);
  d[1]:=0;
  for i:=2 to n do
   d[i]:=maxlongint div 2;
  for i:=2 to p do
   begin
     fir:=1; sec:=1;
     while (sec<=n)and(fir<=n) do
      begin
         dd:=a[fir]; dd:=dd*int64(i);
         while (sec<=n)and(dd>a[sec]) do inc(sec);
         if (dd=a[sec])and(d[sec]>d[fir]+1) then
          begin
            d[sec]:=d[fir]+1;
            if (not used[sec])and(d[sec]+i<=p) then
             begin
              used[sec]:=true;
              if (l<=a[sec])and(a[sec]<=r) then inc(ans);
             end;
          end;
         inc(fir);
      end;
   end;
  writeln(ans);
 end.


Var
  N, l: UInt64;

Begin
  Read(N, l);
  If (N div 2 + N mod 2) >= l then Write(2*l - 1)
  Else If l = N then Write(l - N mod 2)
  Else Write((2*(l mod (N div 2 + N mod 2))))
End.


var a,b,c,i:longint;
begin
  readln(a,b);
  c:=0;i:=0;
  repeat
    inc(c);inc(i);
	if i mod 2 = 1 then begin dec(a,c)
	end else begin dec(b,c) end;
  until (a < 0) or (b < 0) ;
  if b < 0 then writeln('Valera') else writeln('Vladik');
end.


var a:array[1..10,1..10]of longint;
s,d,f,g,h:longint;
begin
read(s);
for d:=1 to s-1 do
a[1,d]:=d;

for f:=2 to s-1 do
for d:=1 to s-1 do
begin
a[f,d]:=a[f-1,d];
for h:=1 to a[1,d]  do
begin
inc(a[f,d]);
if(a[f,d] mod 10)div s>0 then begin inc(a[f,d],10); dec(a[f,d],s); end;
end;
end;

for f:=1 to s-1 do
begin
for d:=1 to s-1 do
write(a[f,d],' ');
writeln;
end;
end.


var
 a:array[0..100,0..100]of longint;
 p1,p2,i,m,n,k,l,w,s,j,x1,y1,x2,y2,l1,l2,e,d:longint;
begin
 readln(n,m,k,s);
 for i:=1 to k do begin readln(p1,p2); a[p1,p2]:=1; end;
 for x1:=1 to n do
 begin
  for y1:=1 to m do
  begin
   for x2:=x1 to n do
   begin
    for y2:=y1 to m do
    begin
     e:=0;
     for l1:=x1 to x2 do
     begin
      for l2:=y1 to y2 do inc(e,a[l1,l2]);
     end;
     if e>=s then inc(w);
    end;
   end;
  end;
 end;
 writeln(w);
end.


              const eps=0.00000001;  besk1=200000008;  nn=600000;
              modul=1000000007;
   besk=8000000000000000000;
   label 1,2,3,4;
    type    real=extended;   double=extended;
    mas=array [-10..nn] of int64;   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 prod,ll,rr,posx,posy,gr,n,dloch,newdl,oldn,oldm,pos1,pos2,ost,ot,aa,bb,cc,p1,p2,p3,p4,kk,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,pmax,imax,t,nm,m,smin,cen:int64;
   mask,k,i1,j1,step1, step, i,j:longint;
   y:mas;
    ppp,prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    oldpos,finot,vv,znak:int64;
    px,py,xc,yc,xxc,yyc:extended;
    pos:array[-1..500001,-1..50] of longint;
    next,prev,x,xx,yy,str,kol,s,time,name,d,dnew, voltay,l,r,c,z,day,b,a:array[-300000..1600000] of int64;
    zz:array[0..125000000] of byte;
    pole:array[-10..1002,-10..1005] of char;
    ddd,dd1,dd2,dd3,dd4,dd,ddsum:array[-10..1201,-10..1220] of int64;
   marked,zanx,zany:array[-10..2000000] of boolean;
    sss1,sss2:string;
    stepen,koled,def,mindef,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
    ss1,ss2,ss:string;ch,ch1,ch2:char;
    binkoef,right,left,numleft,numright,dr: array [-10..60,-10..60] of int64;
    s2,s1:array[-100..200000] of string;

    grr :array [-10..2010,-10..2010] of boolean;
    maxpr:array[0..nn] of string;
    sss:array[-10..nn] of string;
     tx,ty,vel,x1,y1,ott,v0,v1,s0,t0:int64;
     zv:point;
     ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     sq,sqx,sqy,ottt,aaa,bbb,ccc:extended;
     xxx,yyy,yot:double;
       flag2,flag,flag1:boolean;

  function max(a,b:int64):int64;
begin max:=a; if b>a then max:=b;   end;

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   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 summ(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p2+xx.p2*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=t1 div tt mod modul;
    t2:=t2 div tt mod modul;
    ott.p1:=t1; ott.p2:=t2;

   summ:=@ott;
 end;

{     function prod(xx,yy:zap):zap1;
var t1,t2,tt:int64; ott:zap;
 begin
    t1:=(xx.p1*yy.p1) mod modul;
    t2:=(xx.p2*yy.p2) mod modul;
    tt:=nod(t1,t2);
    t1:=(t1 div tt) mod modul;
    t2:=(t2 div tt) mod modul;
    ott.p1:=t1; ott.p2:=t2;

   prod:=@ott;
 end;
 }

 function kkol(kk:int64):int64;
var i,j:longint; ot,sum,pp:int64;
begin
   ot:=0;
   pp:=p;
   while pp>0 do
     begin
        ot:=ot+min(kk,pp);
        pp:=pp- min(kk,pp);
        pp:=pp-(pp div 10);

     end;
   kkol:=ot;

end;

    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 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 shr 1); degg:=p*p mod modul;   end;

end;

{function prost(tt:longint):boolean;
var aa:extended; i,p,t:longint;  fl:boolean;
 begin
   fl:=true;
   aa:=tt;
   aa:=sqrt(aa);
   t:=round(aa);
   for i:=2 to t do if tt mod i=0 then fl:=false;

   prost:=fl;
 end;
 }
function arcsin(pp:extended):extended;
var tt:extended;
begin
   if (abs(pp)<=1+eps)and (abs(pp)>=1-eps)
   then if pp>0 then arcsin:=pi/2 else arcsin:=-pi/2;
   tt:=1-pp*pp;
   if abs(tt)>=0 then
     begin
        arcsin:=arctan(pp/sqrt(tt));

     end;

end;

function otprod(var xx:mas):int64;
label 88;
var i,j:longint; ot,pp:int64;
begin
  ot:=1;  pp:=0;
 { for i:=0 to 9 do write(xx[i],' ');
 } for i:=0 to 9 do pp:=pp+xx[i];
 { writeln('sum= ',pp);
 } for i:=0 to 9 do if i>0 then begin ot:=ot*binkoef[pp,xx[i]]; {writeln('i= ',i,'  pp= ',pp,' xx= ',xx[i],'  koef= ',binkoef[pp,xx[i]]);} pp:=pp-xx[i]; end
 else begin ot:=ot*binkoef[pp-1,xx[i]]; { writeln('i= ',i,'  pp= ',pp,' xx= ',xx[i],'  koef= ',binkoef[pp,xx[i]]);} pp:=pp-xx[i]; end;

88:
  otprod:=ot;
end;

begin

   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }

     read(p);
     while p>0 do begin inc(q); a[q]:= p mod 10; p:=p div 10;  end;

     for i:=1 to q do inc(x[a[i]]);
           n:=q;
   {  for i:=0 to 9 do write(x[i],' '); writeln;
   }  binkoef[0,0]:=1;
     for i:=1 to 30 do for j:=-1 to i+1 do binkoef[i,j]:=binkoef[i-1,j]+binkoef[i-1,j-1];
    { for i:=0 to 20 do begin  for j:=0 to i do write(binkoef[i,j],' '); writeln; end;
     }
     pp:=1;
     for i:=0 to 9 do if x[i]>0 then pp:=pp*x[i];

    { write('otprod= ');
     y[0]:=1; y[2]:=2; y[8]:=1;
     writeln(otprod(y));
   } for mask:=0 to pp-1 do
      begin
         t:=mask;     for i:=0 to 9 do y[i]:=0;
         for i:=0 to 9 do if x[i]>0 then begin y[i]:=t mod x[i]+1; t:=t div x[i];  end;
       {  writeln('mask= ',mask);
         for i:=0 to 9 do write(y[i],' '); writeln; writeln('  dob= ',otprod(y)); writeln;
       }  ot:=ot+ otprod(y);

      end;

     writeln(ot);

   1:          close(output);
end.


var
  n, a, b, c, d, y, m, k, ans: int64;
  x: longint;

begin
    readln(n, a, b, c, d);
    for x:= 1 to n do
        begin
            y:= b - c + x;
            m:= a - d + x;
            k:= y + a - d;
            if (y >= 1) and (y <= n) and (m >= 1) and (m <= n)
                and (k >= 1) and (k <= n) then inc(ans);
        end;
    writeln(ans * n);
end.


Const finp='';
      fout='';
Var n,lc:longint;
    fb:array[0..1000] of longint;
    kq:array[1..3] of longint;

Procedure Nhap;
Var f:text;
Begin
    Assign(f,finp);
    reset(f);
    Readln(f,n);
    Close(f);
End;

Procedure Xuly;
Var i,d,t,k:longint;
Begin
    If n=0 then Exit;
    If n=1 then
        Begin
            kq[1]:=1;
            Exit;
        End;
    fb[0]:=0;
    fb[1]:=1;
    fb[2]:=1;
    For i:=3 to 45 do
        Begin
            fb[i]:=fb[i-1]+fb[i-2];
            If (fb[i]>=n) and (fb[i-1]<n) then
                Begin
                    k:=i;
                    Break;
                End;
        End;
    d:=0;
    Repeat
         For i:=k downto 1 do
             Begin
                 If (fb[i]<n) then
                    Begin
                        n:=n-fb[i];
                        inc(d);
                        kq[d]:=fb[i];
                    End;
                 If fb[i]=n then
                    Begin
                        If d=2 then kq[3]:=fb[i];
                        If d=1 then
                           Begin
                               kq[2]:=fb[i-1];
                               kq[3]:=fb[i-2];
                           End;
                        If d=0 then
                           Begin
                               kq[1]:=fb[i-2];
                               kq[2]:=fb[i-2];
                               kq[3]:=fb[i-3];
                           End;
                        Exit;
                    End;
             End;
    Until d=3;
End;

Procedure Xuat;
Var f:text;
    i:longint;
Begin
    Assign(f,fout);
    Rewrite(f);
    For i:=1 to 3 do Write(f,kq[i],' ');
    Close(f);
End;

Begin
    Nhap;
    Xuly;
    Xuat;
End.


var w,h,answer,i:int64;
begin
read (w);
readln (h);
answer:=1;
for i:=1 to w+h do
answer:= (2*answer) mod 998244353;
writeln (answer);
end.


var t1,t2,i,j,k,l,m,n,h,s:longint;
    j1,j2,j3,jt1,jt2,p:double;
begin
    readln(h,m,s,t1,t2);
    j3:=s*6;
    j2:=m*6+s/10;
    j1:=(h*30);
    j1:=j1+(m/4)+(s/240);
    if j1>360 then j1:=j1-360;
    jt1:=t1*30;
    jt2:=t2*30;
    if jt1>jt2 then  begin p:=jt1; jt1:=jt2; jt2:=p; end;
    if (jt1<j1)and(jt1<j2)and(jt1<j3)and(j2<jt2)and(j1<jt2)and(j3<jt2)then
       begin
           writeln('Yes');
           halt;
       end;
    if((j1<jt1)or(j1>jt2))and((j2<jt1)or(j2>jt2))and((j3<jt1)or(j3>jt2))then
       begin
           writeln('YES');
           halt;
       end;
       writeln('No');
end.


var n,m,k,ans,x,tmp,kk,i,j,l1,l2,l:longint;
ss:string;
q,w:array[0..200]of longint;
a,b,c:array[0..200,0..200]of longint;
 begin
  readln(n,m,k);
  for i:=1 to n do
    begin
     readln(ss);
     for j:=1 to m do
       readln(a[i,j],b[i,j],c[i,j]);
    end;

  ans:=0;

  for i:=1  to n do
    for j:=1 to n do
      begin
       for l:=1 to m do
        begin
         q[l]:=b[j,l]-a[i,l];
         w[l]:=c[i,l];
        end;

       for l1:=1 to m do
         for l2:=l1+1 to m do
           if q[l1]<q[l2] then
             begin
              x:=q[l1];
              q[l1]:=q[l2];
              q[l2]:=x;

              x:=w[l1];
              w[l1]:=w[l2];
              w[l2]:=x;
             end;

       kk:=k;
       tmp:=0;
       for l:=1 to m do
        if q[l]>0 then
         if kk>w[l] then
           begin
            kk:=kk-w[l];
            tmp:=tmp+w[l]*q[l];
           end else
           begin
            tmp:=tmp+kk*q[l];
            break;
           end;

       if tmp>ans then ans:=tmp;
      end;

  writeln(ans);
 end.


Var n,i:longint;
    x,y:int64;
    a:array [1..10000000] of int64;
    function min (a1,b1:int64):int64;
  begin
   min:=a1;
   if a1>b1 then min:=b1;
   end;
     Begin
      read(n,x,y);
      a[1]:=x;
      for i:=2 to n do
         if i mod 2=0 then a[i]:=min(a[i-1]+x,a[i div 2]+y)
                      else a[i]:=min(a[i-1]+x,a[(i div 2)+1]+x+y);
      writeln(a[n]);
      End.


var
  s:string;
  x,y,ans:longint;
begin
  read(s);
  if (s[1]='a') or (s[1]='h') then x:=1;
  if (s[2]='1') or (s[2]='8') then y:=1;
  if (x=1) and (y=1) then inc(ans);
  if x=1 then dec(ans,3);
  if y=1 then dec(ans,3);
  write(ans+8);
end.


program lt;
var
  a,b,x,y:longint;

function gcd(x,y:longint):longint;
begin
  if x mod y=0 then gcd:=y
    else gcd:=gcd(y,x mod y);
end;

procedure work;
var
  k,w,k1,k2:longint;
begin
  readln(a,b,x,y);
  w:=gcd(x,y);
  x:=x div w;y:=y div w;
  k1:=a div x;
  k2:=b div y;
  if k1<k2 then k:=k1
           else k:=k2;
  writeln(x*k,' ',y*k);
end;

begin
  work;
end.


const co=1000000000;
var n,x,y,ans,i,j,ai,aj:int64;f:boolean;
begin
readln(n,x,y);
n:=n*6;
if x*y>n then begin writeln(x*y); writeln(x,' ',y); halt; end;
i:=x;
ans:=-1;
while i*i<=n*2 do begin
  j:=n div i;
  if i*j<n then inc(j);
  if y>j then j:=y;
  if (i*j<ans) or (ans=-1) then begin ans:=i*j;ai:=i;aj:=j; end;
  inc(i);
end;
j:=y;
while j*j<=n*2 do begin
  i:=n div j;
  if i*j<n then inc(i);
  if x>i then i:=x;
  if (i*j<ans) or (ans=-1) then begin ans:=i*j;ai:=i;aj:=j; end;
  inc(j);
end;
writeln(ans);
writeln(ai,' ',aj);
end.


program project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Math;

var j, p, q, p1, p2 : int64;
  ss : string;
  s : integer;
  i : integer;

function f(q : int64; l, r : int64):integer;
var t : int64;
begin
  t := (l+r) div 2;
  if (t*t <= q) and ((t+1)*(t+1) > q) then begin result := t; exit; end;
  if t*t < q then result := f(q, t+1, r) else result := f(q, l, t-1);
end;

function pr (q : int64) : boolean;
var i, s : integer;
begin
  result := false;
  //s := f(q, 1, q);
  s := trunc(sqrt(q + 0.0));
  for i := 2 to s do if q mod i = 0 then exit;
  result := true;
end;

begin
//  assign (input, 'input.txt');
//  assign (output, 'output.txt');
//  reset (input);
//  rewrite (output);
  readln(ss);                             {
  if length(ss) <= 7 then q := strtoint(ss) else
    q := strtoint(copy(ss, 1, length(ss)-7))*10000000 +
    strtoint(copy(ss, length(ss)-6, 7)); }
  for i := 1 to length(ss) do begin
    q := q*10 + strtoint(ss[i]);
  end;

 // s := f(q, 1, q);
 s := trunc(sqrt(q+0.0));
  if pr(q) then begin
    writeln (1);
    writeln(0);
  end
    else
  begin
    for i := 2 to s do
    if (q mod i) = 0 then begin
      p1 := i;
      break;
    end;
    p := q div p1;
    if pr(p) then write (2) else begin
      for i := 2 to s do
      if (p mod i) = 0 then begin
        p2 := i;
        break;
      end;
      writeln (1);
      write (p1*p2);
    end;
  end;

//  close (input);
//  close (output);
end.
--------------------------------------------------------------------------------


Program z4b;
var d,sum,i,j,sum1:integer;
	a:array[1..2,1..30]of integer;
    k:array[1..30]of integer;
begin
	read(d,sum);
    for i:=1 to d do
    begin
    	read(a[1,i],a[2,i]);
        k[i]:=a[2,i];
        sum1:=sum1+k[i];
    end;
    if sum1<sum then begin write('NO');halt;end;
    i:=1;
    while (i<=d)and(sum1<>sum) do
    begin
    	if sum1-(k[i]-a[1,i])>=sum then
        begin
        	sum1:=sum1-(k[i]-a[1,i]);
            k[i]:=a[1,i];
        end
        else
        begin
        	k[i]:=k[i]-(sum1-sum);
        	sum1:=sum;
        end;
        inc(i);
    end;
    if sum1=sum then
    begin
    	writeln('YES');
        for i:=1 to d do
        	write(k[i],' ');
    end
    else write('NO');
end.


var t,s,x:integer;
begin
read(t,s,x);
if (x<t) or (x=t+1) then write('NO')
else if (((x-t-1) mod s=0) and (x<>t+1)) or ((x-t) mod s=0) then write('YES')
else write('NO');
end.


var a,w,row,col:array[0..100] of longint;
    i1,i2,i3,i4,main,i,adv,n,s:longint;
    used:array[0..10000] of boolean;
    res:array[0..17,0..17] of longint;
    a4:array[0..17,0..17,0..17,0..17] of boolean;
    a3:array[0..17,0..17,0..17] of boolean;
    a2:array[0..17,0..17] of boolean;

   procedure rec(v:longint);
    var i:longint;
        flag:boolean;
    begin
      flag:=false;
      for i:=1 to n*n do
       begin
         if not used[i] then
          begin
            flag:=true;
            used[i]:=true;
            inc(col[v mod n],a[i]);
            inc(row[v div n],a[i]);
            w[v]:=a[i];
            if (v mod n=v div n) then inc(main,a[i]);
            if (v mod n+v div n=n-1) then inc(adv,a[i]);

            rec(v+1);

            used[i]:=false;
            dec(col[v mod n],a[i]);
            dec(row[v div n],a[i]);
            if (v mod n=v div n) then dec(main,a[i]);
            if (v mod n+v div n=n-1) then dec(adv,a[i]);
          end;
       end;
      if not flag then
       begin
         for i:=0 to n-1 do
          if col[i]<>s then exit;
         for i:=0 to n-1 do
          if row[i]<>s then exit;

         if (main=s)and(adv=s) then
          begin
            for i:=0 to n*n-1 do
             begin
               if i mod n=0 then writeln;
               write(w[i],' ');
             end;
            writeln;
            halt(0);
          end;
       end;
    end;

   procedure rec2(x,y:longint);
    var i,j:longint;
    begin
      if (x=4) then
       begin
         if a4[res[0][0],res[1][1],res[2][2],res[3][3]]
        and a4[res[0][3],res[1][2],res[2][1],res[3][0]] then
         begin
           for i:=0 to 3 do
            begin
              for j:=0 to 3 do
               write(a[res[i][j]],' ');
              writeln;
            end;
           halt(0);
         end;
         exit;
       end;
      for i:=1 to n*n do
       if not used[i] then
        begin
          res[x][y]:=i;

          if (x=1)and (not a2[res[x][y],res[x-1][y]]) then continue;
          if (x=2)and (not a3[res[x][y],res[x-1][y],res[x-2][y]]) then continue;
          if (x=3)and (not a4[res[x][y],res[x-1][y],res[x-2][y],res[x-3][y]]) then continue;

          if (y=1)and (not a2[res[x][y],res[x][y-1]]) then continue;
          if (y=2)and (not a3[res[x][y],res[x][y-1],res[x][y-2]]) then continue;
          if (y=3)and (not a4[res[x][y],res[x][y-1],res[x][y-2],res[x][y-3]]) then continue;

          if (x=y) then
           begin
             if (x=1)and(not a2[res[x-1][y-1],res[x][y]]) then continue;
             if (x=2)and(not a3[res[x-1][y-1],res[x][y],res[x-2][y-2]]) then continue;
             if (x=3)and(not a4[res[x-1][y-1],res[x][y],res[x-2][y-2],res[x-3][y-3]]) then continue;
           end;

          used[i]:=true;
          rec2(x+(y+1) div 4,(y+1) mod 4);
          used[i]:=false;
        end;
    end;
 begin
  read(n);
  for i:=1to n*n do
   begin
     read(a[i]);
     s:=s+a[i];
   end;

  for i:=1 to 1000 do
   begin
     i1:=random(n*n)+1;
     i2:=random(n*n)+1;
     a[0]:=a[i1]; a[i1]:=a[i2]; a[i2]:=a[0];
   end;
  s:=s div n;
  if n<=3 then
   begin
     write(s);
     rec(0);
   end;

  writeln(s);
  for i1:=1 to n*n do
   for i2:=1 to n*n do
    for i3:=1 to n*n do
     for i4:=1 to n*n do
      begin
        if (i1=i2)or(i1=i3)or(i1=i4)or(i2=i3)or(i2=i4)or(i3=i4) then
        else
         begin
           if a[i1]+a[i2]+a[i3]+a[i4]=s then
            begin
              a4[i1][i2][i3][i4]:=true;
              a3[i1][i2][i3]:=true;
              a2[i1][i2]:=true;
            end;
         end;
      end;

   rec2(0,0);

 end.


var
  c1,c0:array[0..101,0..101] of longint;
  a:array[1..100] of longint;
  n,j,k,l,i,ans,aw:longint;

function max(x,y:longint):longint;
begin
  if x>y then exit(x)
         else exit(y);
end;

begin
  readln(n);
  aw:=0;
  for i:=1 to n do
  begin
    read(a[i]);
    if a[i]=1 then begin c1[1,i]:=c1[1,i-1]+1; c0[1,i]:=c0[1,i-1]; inc(aw); end
              else begin c0[1,i]:=c0[1,i-1]+1; c1[1,i]:=c1[1,i-1]; end;
  end;
  for i:=1 to n do
    for j:=i to n do
    begin
      if a[i]=1 then begin c1[i+1,j]:=c1[i,j]-1; c0[i+1,j]:=c0[i,j]; end
                else begin c0[i+1,j]:=c0[i,j]-1; c1[i+1,j]:=c1[i,j]; end;
    end;
  for i:=1 to n do
    for j:=i to n do
      ans:=max(ans,aw+c0[i,j]-c1[i,j]);
  if (a[1]=1) and (n=1) then writeln(0)
                        else writeln(ans);
end.


const
   p=1000000007;

var
   n,i,q,r:longint;
   s:string;
   a:array[0..1000]of longint;
begin
   readln(s); n:=length(s);
   q:=1;
   for i:=1 to n+n do
      begin
      q:=(q+q)mod p;
      a[i]:=q;
      end;
   a[0]:=1;
   r:=0;
   for i:=1 to n do
      if s[i]='1' then r:=(r+a[n+n-i-1])mod p;
   write(r);
end.


Var i, a,b,m,r, ikin, iper, len:longint;
Var p:boolean;
Var nr:array[0..100001] of longint;
begin
read(a,b,m,r);

i:=1;
p:=false;
while not p do
 Begin
 r:=(a*r+b)mod m;
 if nr[r]=0 then nr[r]:=i
 else
  begin
  ikin:=i;
  iper:=nr[r];
  p:=true;
  end;
 i:=i+1;
 end;

if p then
 len:=ikin-iper;
writeln(len);

end.


Var
  n,i,i1,i2,s:integer;
  a:array [1..10,1..10] of integer;
begin
  s:=0;
  readln(n);
  for i:=1 to n do a[1,i]:=1;
  for i:=1 to n do a[i,1]:=1;

  for i:=2 to n do
  for i2:=2 to n do
  a[i,i2]:=a[i-1,i2]+a[i,i2-1];
  for i:=1 to n do
  for i2:=1 to n do
  if s<a[i,i2] then s:=a[i,i2];

  writeln(s);
end.


const
        mo                      =1000000007;
var
        n                       :longint;
        m                       :int64;
        a                       :array[0..100] of int64;
        i,j                     :longint;
        ans                     :array[0..100] of int64;
        b                       :array[0..100] of longint;
        ni                      :int64;
        aa                      :int64;
function pow(x,y:int64):int64;
var
        ans                     :int64;
begin
    ans:=1;
    while y>0 do
    begin
        if y and 1=1 then ans:=ans*x mod mo;
        y:=y >> 1;
        x:=x*x mod mo;
    end;
    exit(ans);
end;
function calc(x:int64):int64;
var
        ans                     :int64;
begin
    if x<0 then exit(0);
    if x=0 then exit(1);
    ans:=1;
    for i:=1 to n-1 do
    begin
        ans:=ans*((x+i) mod mo) mod mo;
    end;
    ans:=ans*ni mod mo;
    exit(ans);
end;
procedure check;
var
        i,j                     :longint;
        cur                     :int64;
        cnt                     :longint;
begin
    cur:=m; cnt:=0;
    for i:=1 to n do
    begin
        if b[i]=1 then
        begin
            cur:=cur-a[i]-1 ;
            inc(cnt);
        end;
    end;
    ans[cnt]:=(ans[cnt]+calc(cur)) mod mo;
end;
procedure dfs(x:longint);
begin
    if x=n+1 then
    begin
        check;
        exit;
    end;
    b[x]:=0;
    dfs(x+1);
    b[x]:=1;
    dfs(x+1);
end;
begin
    read(n,m);
    for i:=1 to n do read(a[i]);
    ni:=1;
    for i:=1 to n-1 do ni:=ni*int64(i) mod mo;
    ni:=pow(ni,mo-2);
    dfs(1);
    for i:=0 to n do
    begin
        if i and 1=0 then aa:=(aa+ans[i]) mod mo else aa:=(aa-ans[i]+mo) mod mo;
    end;
    writeln(aa);
end.


                 program pr1;

{$APPTYPE CONSOLE}
 type extended=int64;
 zap=record p1,p2,p3:int64;end; zap1=^zap;
     chislo=record ch,st:int64;end; chislo1=^chislo;
const nn=1000001; besk=200000000000000;
   nnn=2000000;  eps=1e-14;
 label 1,2,3,4;
var i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;
k3,k4,k5,ot,p,t,t2,dx1,dy1,t1old,t2old,f,c,n,mmin,imin,p1,p2,s,l,m,k1,k2,a2:int64;
centr,aa,bb,cc,koef:int64;  ch,ch1,ch2:char;
ott:zap; ott1:zap1;
r,num,x,y,b,r1,r2:array[0..1000000] of extended;
flag2,flag1,flag:boolean;
c1,c2:char;
good,good1:array[0..1000000] of boolean;
ppp:array[0..1000000] of int64;
gr:array['a'..'z','a'..'z'] of boolean;
dd :double;
namemin:string;
ss:string;{array[0..1100000] of char;}
name:array[0..2000] of string;
function min (a,b:extended):extended;begin min:=b;if a<b then min:=a;  end;
function max (a,b:extended):extended;begin max:=b;if a>b then max:=a;  end;

function nod(a,b:longint):longint; var p,t:longint;
begin if (a>0)and(b>0) then
   begin while (b>0) do begin t:=a mod b;a:=b;b:=t;    end;
    p:=a;
   end else if a=0 then p:=b else p:=a;
nod:=p;
end;

            function evkl(a,b:int64):zap1;   label 44;
 var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64; fl:boolean;
      tt:zap; tt1:zap1;
    begin
      fl:=false;
      if a<b then begin r:=a;a:=b;b:=r; fl:=true;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;
     if  fl then begin
        d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;  end;

     if not fl then begin
        d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p3:=x;tt.p2:=y; tt1:=@tt;  end;

    44:   evkl:=tt1;
    end;

 {a*x+b*y=c v pol x,y}
 function razl(a,b,c:int64):boolean;
 label 22;
 var l,r,x0,y0,t1,t2,t3,i,j,k:int64; fl:boolean;  xx:zap;
begin
 if c mod nod(a,b)<>0 then begin fl:=false; goto 22;  end;
    xx:=evkl(a,b)^;
    x0:=xx.p3; y0:=xx.p2;
    if a*x0+b*y0=c then begin l:=x0; x0:=y0;y0:=l    end;
    l:=trunc(-x0*c/b-eps)+1; r:=trunc(y0*c/a+eps);
    { writeln('l=',-x0*c/b:0:5 ,' r= ',y0*c/a:0:5); }
    if l<=r then fl:=true else fl:=false;

22: razl:=fl;
end;

    {min raz abs(a*x-b*y) a*x+b*y=c}
  function minraz(a,b,c:int64):int64;
 label 23;
 var l,r,x0,y0,t1,t2,t3,j,k:int64; fl:boolean;  xx:zap; i:longint;
begin
    xx:=evkl(a,b)^;
    x0:=xx.p3; y0:=xx.p2;
    if a*x0+b*y0=c then begin l:=x0; x0:=y0;y0:=l    end;
    l:=trunc(-(a*c*x0-b*c*y0)/(2*a*b));

  k:=10000000000000;
    for i:=l-1 to l+1 do
  begin r:=i;
    k:=min(k,abs(a*c*x0-b*c*y0+2*a*b*r));
  end;
23: minraz:=k;
end;

begin
{assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
}      readln(n);
   if n=3 then begin  writeln(5); goto 1;      end;
       for i:=0 to 200 do ppp[i]:=((2*i+1)*(2*i+1)+1) div 2;
     for i:=0 to 200 do if ppp[i]>=n then begin    writeln(2*i+1);goto 1;end;

   1:          close(output);
end.


program problem3;

var	x1, y1, x2, y2: longInt;

begin
	readln( x1, y1, x2, y2 );

	while ( true ) do
	begin
		if ( x2 - y2 < x1 - y1 ) and ( x1 > 0 ) and ( ( x1 <> x2 + 1 ) or ( y1 <> y2 ) ) then
			dec( x1 )
		else if ( y1 > 0 ) and ( ( y1 <> y2 + 1 ) or ( x1 <> x2 ) ) then
			dec( y1 )
		else if ( x1 > 0 ) and ( ( x1 <> x2 + 1 ) or ( y1 <> y2 ) ) then
			dec( x1 );

		if ( x1 + y1 = 0 ) then
		begin
			writeln( 'Polycarp' );

			halt;
		end;

		if ( x2 > 0 ) and ( y2 > 0 ) and ( ( x2 <> x1 + 1 ) or ( y2 <> y1 + 1 ) ) then
		begin
			dec( x2 );
			dec( y2 );
		end
		else if ( x2 > 0 ) and ( ( x2 <> x1 + 1 ) or ( y2 <> y1 ) ) then
			dec( x2 )
		else if ( y2 > 0 ) and ( ( y2 <> y1 + 1 ) or ( x2 <> x1 ) ) then
			dec( y2 );

		if ( x2 + y2 = 0 ) then
		begin
			writeln( 'Vasiliy' );

			halt;
		end;
	end;
end.


var a,b,n,m:longint;

begin
readln(n,m,a,b);
if ((((a-1) div m=(b-1) div m))or(m>=n)or(a=b)or( ((a-1) mod m=0)and(((b mod m=0)or(b=n)))))
 then writeln(1) else
begin
if  (( (((a-1) mod m=0)or(((b mod m=0)or(b=n))))
      ) or (  (b-1) mod m+1=(a-1) mod m  )or( (a-1) div m+1=(b-1) div m ))
 then writeln(2) else writeln(3);
end;
readln;
  { TODO -oUser -cConsole Main : Insert code here }
end.


{$r-, s-, q-, i-, o+}
const max_sum = 600000;
var
  n, d, i, j, x, k, cur, steps : longint;
  changed : boolean;
  f : array [0..max_sum + max_sum] of boolean;
  s : array [0..max_sum + max_sum] of longint;
begin
  f[0] := true;
  readln(n, d);
  for i := 1 to n do
    begin
      read(x);
      for j := max_sum downto 0 do
        f[j + x] := (f[j]) or (f[j + x]);
    end;
  cur := 0;
  steps := 0;
  while (true) do
    begin
      changed := false;
      for i := cur + d downto cur + 1 do
        if (f[i]) then
          begin
            changed := true;
            cur := i;
            inc(steps);
            break;
          end;
      if (not changed) then break;
    end;
  writeln(cur, ' ', steps);
end.


Var
	m,top:longint;

Begin
	readln(m);
	top:=0;
	repeat
		inc(top);
		m:=m div 2;
	until m=0;
	writeln(top);
End.


var a,b,c:longint;
begin
read(a,b,c);
if (a>b) and (a>c) then
 if a+b+c<2*(c+b) then write(a+b+c) else write(2*(c+b))
else if (b>c) and (b>a) then
 if a+b+c<2*(a+c) then write(a+b+c) else write(2*(c+a))
else
 if a+b+c<2*(a+b) then write(a+b+c) else write(2*(a+b));
end.


   const nn=6000; nnn=2000;eps=0.000000001;  besk1=200000008;
   label 1,2;
    type    real=extended;  {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 modul,tt,ii,sumplus,summinus,pp,ot,q,ll,rr,aa,bb,cc,p1,p2,l,r,pos,t,kolx,kolo,nm,n,k,s1,s2,m,s,imax,smin,cen,dl,t2,i1,p,besk:int64;
    step, i,j:longint;
     time:real;
     sss:array[-10..10000] of char;
     buk,sssnew:array[-10..1000] of char;
     sum,sumii,c,d,x,y,a,b:array[-1000002..6000000] of int64;
     dda,ddb:array[-10..1200,-10..1200] of int64;
     ss1,ss2:string;
    ss:string;ch:char;
    maxpr:array[0..nn] of string;
    st2:array[0..nnn] of string;
     v0,v1,s0,t0:real;
     zv:point;
     xx,yy:array[-1..nn] of double;
     yot:double;
     prost:array [-1000..6000000] of boolean;
       flag,flag1:boolean;
    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 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;

function kolizm(pos:longint):longint;
var i,j,ot:longint;
begin
  ot:=0;
  for i:=1 to p1 do if ss1[i]<>ss2[pos+i-1] then inc(ot);

  kolizm:=ot;
end;

begin
  { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }

      read(tt,ll,rr);  modul:=1000000007;
      n:=rr;
      for i:=1 to 5000000 do prost[i]:=true;
      p:=1;
      while p<=n do
        begin
           repeat inc(p) until prost[p];
           t:=(n div p);
           for i:=2 to t do begin prost[p*i]:=false;   end;

        end;

     { for i:=2 to 100 do if prost[i] then write(i,' '); writeln;
     } for i:=2 to n do a[i]:=0;
        p:=1;
       a[1]:=0;
      while p<=n do
        begin
           repeat inc(p) until prost[p];
           t:=n div p;
           a[p]:=p;
           for i:=2 to t do
          begin
               a[i*p]:=max(a[i*p],p);

          end;
        end;

      { for i:=1 to 50 do write(a[i],' '); writeln;
     } for i:=2 to n do
        begin
           t:=i div a[i];
          { writeln(i,' ',t);
           writeln(a[t],' + ',((a[i]*(a[i]-1) shr 1)));
         } b[i]:=(a[i]*b[t]+(a[i]*(a[i]-1) shr 1)) mod modul;
         { writeln('i= ',i,' b= ',b[i]);
          writeln('---------');
        }end;
     { writeln('+++++++++++++');
       for i:=2 to 1000 do writeln(i,' ',b[i],' '); writeln;
      }

   {  ot:=0;
     x[ll]:=1;
     for i:=ll+1 to rr do x[i]:=(x[i-1]*tt) mod modul;
     for i:=ll to rr do
       begin
          ot:=(ot+b[i]*x[i]) mod modul;

       end;
       writeln(ot);
       ot:=0;
       p:=1;

    }
    ot:=0;
     for i:=rr downto ll do
       begin
          ot:=(ot*tt+b[i])mod modul;
         { writeln('i= ',i,' b= ',b[i],' ot= ',ot); }
       end;

       writeln(ot );

   1:          close(output);
end.


//mathfuck

const
     md=1000000007;

var
   F,INV:array[0..1000002] of qword;
   i,n,k:longint;
   s,ans,tmp,w:qword;

function Pow(i:qword; k:longint):qword;
var r:qword;
begin
     r:=1;
     while k>0 do
     begin
          if k and 1 = 1 then r:=r*i mod md;
          i:=i*i mod md;
          k:=k div 2;
     end;
     exit(r);
end;

begin
     readln(n,k);
     s:=1; INV[0]:=1; tmp:=1;
     for i:=1 to k+2 do
     begin
          tmp:=tmp*(n-i) mod md;
          s:=s*i mod md;
          F[i]:=(F[i-1]+Pow(i,k)) mod md;
          INV[i]:=Pow(s,md-2);
     end;
     if n<=k+2 then ans:=F[n] else
          for i:=1 to k+2 do
          begin
               w:=INV[i-1]*INV[k+2-i] mod md;
               if (k-i) and 1 = 1 then w:=md-w;
               ans:=(ans+((tmp*Pow(n-i,md-2) mod md)*(w*F[i] mod md) mod md)) mod md;
          end;
     write(ans);
end.


uses math;
var x,y,xx,yy,ans,r:int64;
m:double;
begin
 readln(r,x,y,xx,yy);
 r:=r*2;
 m:=sqrt(sqr(xx-x)+sqr(yy-y));
 writeln(ceil(m/r));
end.


type
  re=record
       x,y:extended;
       adj:longint;
     end;

var
  ans,t1,t2:extended;
  n,m:longint;
  a:array[1..100100]of re;

function jd(x,y:re):boolean;
begin
  exit(x.x<y.x);
end;

function min(x,y:extended):extended;
begin
  if x<y then exit(x);
  exit(y);
end;

procedure qs(l,r:longint);
var
  i,j:longint;
  mid,t:re;

begin
  if l>=r then exit;
  i:=l;
  j:=r;
  mid:=a[(l+r)shr 1];
  repeat
    while jd(a[i],mid) do inc(i);
    while jd(mid,a[j]) do dec(j);
    if i<=j then begin
      t:=a[i];
      a[i]:=a[j];
      a[j]:=t;
      if i=m then m:=j
      else if j=m then m:=i;
      inc(i);
      dec(j);
    end;
  until i>j;
  qs(i,r);
  qs(l,j);
end;

function dis(x,y:re):extended;
begin
  exit(sqrt(sqr(x.x-y.x)+sqr(x.y-y.y)));
end;

procedure init;
var
  i,l,r:longint;

begin
  for i:=1 to n+1 do begin
    read(a[i].x);
    a[i].adj:=i;
  end;
  read(a[n+1].y);
  qs(1,n);
  if m=a[n+1].adj then begin
    ans:=a[n].x-a[1].x;
    t1:=dis(a[n],a[n+1]);
    t2:=dis(a[1],a[n+1]);
    ans:=ans+min(t1,t2);
  end
  else begin
    ans:=min(dis(a[n],a[n+1])+dis(a[m],a[1]),dis(a[1],a[n+1])+dis(a[m],a[n]))
         +dis(a[1],a[n]);

    for i:=2 to n do begin
      t1:=min(dis(a[m],a[1])+dis(a[1],a[i-1])+dis(a[i-1],a[n+1]),dis(a[m],a[i-1])+dis(a[i-1],a[1])+dis(a[1],a[n+1]))
          +min(dis(a[n],a[n+1]),dis(a[i],a[n+1]))+dis(a[n],a[i]);
      t2:=min(dis(a[m],a[n])+dis(a[n],a[i])+dis(a[i],a[n+1]),dis(a[m],a[i])+dis(a[i],a[n])+dis(a[n],a[n+1]))
          +min(dis(a[1],a[n+1]),dis(a[i-1],a[n+1]))+dis(a[1],a[i-1]);
      ans:=min(ans,min(t1,t2));
    end;
  end;
  writeln(ans:0:8);
end;

begin
  readln(n,m);
  init;
end.


{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}
var
  yy,zz,n,m,i,e: longint;
  lg,rg: array [0..2,0..1,0..110] of longint;
  kg: array [0..2,0..1] of longint;
  was: array [0..100010,0..2,0..1] of boolean;
  x,y,z,km: array [0..666666] of longint;

procedure put(x1,x2,yy,zz:longint);
var
  u1,u2,v,j,xx: longint;
begin
  if x2 < 0 then exit;
  if x1 > n then exit;
  zz:=1-zz;
  yy:=2-yy;
  if x1 < 0 then x1:=0;
  if x2 > n then x2:=n;
  xx:=x1; x1:=n-x2; x2:=n-xx;
  u1:=x1; u2:=x2;
  for v:=1 to kg[yy,zz] do
  begin
    if x1 < lg[yy,zz,v] then x1:=lg[yy,zz,v];
    if x2 > rg[yy,zz,v] then x2:=rg[yy,zz,v];
    for j:=x1 to x2 do
      if not was[j,yy,zz] then
      begin
        inc(e);
        x[e]:=j;
        y[e]:=yy;
        z[e]:=zz;
        km[e]:=km[i]+1;
        was[j,yy,zz]:=True;
      end;
    if x1 <= x2 then
      if (x1 > lg[yy,zz,v]) and (x2 < rg[yy,zz,v]) then
      begin
        inc(kg[yy,zz]);
        lg[yy,zz,kg[yy,zz]]:=x2+1;
        rg[yy,zz,kg[yy,zz]]:=rg[yy,zz,v];
        rg[yy,zz,v]:=x1-1;
      end else
      if x2 < rg[yy,zz,v] then lg[yy,zz,v]:=x2+1
      else rg[yy,zz,v]:=x1-1;
    x1:=u1; x2:=u2;
  end;
end;

begin
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  read(n,m);
  for yy:=0 to 2 do
    for zz:=0 to 1 do
    begin
      kg[yy,zz]:=1;
      lg[yy,zz,1]:=0;
      rg[yy,zz,1]:=n;
    end;
  fillchar(was,sizeof(was),False);
  i:=1; e:=1;
  x[1]:=n; y[1]:=2; z[1]:=0;
  km[1]:=0;
  was[n,2,0]:=True;
  while i <= e do
  begin
    if (x[i] = n) and (y[i] > 0) and (z[i] = 1) then
    begin
      writeln(km[i]);
      halt;
    end;
    if y[i] = 0 then
    begin
      put(x[i]-m,x[i]-1,0,z[i]);
    end else
    if y[i] = 1 then
    begin
      put(x[i]-(m shr 1),x[i]-1,1,z[i]);
      if (x[i] > 0) and (x[i] <= m) then put(x[i]-(m-x[i]),x[i],0,z[i]);
    end else
    begin
      put(x[i]-m,x[i]-1,2,z[i]);
      if (n-x[i]) <= m then
        if x[i] < n then put(x[i]-((m-(n-x[i])) shr 1),x[i],1,z[i])
        else put(x[i]-(m shr 1),x[i]-1,1,z[i]);
    end;
    inc(i);
  end;
  writeln(-1);
  close(input);
  close(output);
end.


var
  c, ex, a, b, n, i, v, x, code: int64;
  s1: string;
  s2:string;

begin
v:=1;
  readln(s1);
  readln(s2);

for i:=1 to length(s2) do
begin
if s2[i]=s1[v] then
begin
v:=v+1;
c:=c+1;
end;
end;

writeln(c+1);

end.


uses math;

var
  i,j,n,w,kq:integer;
  a:array[0..200] of integer;

begin
  read(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to n do
    begin
      w:=0;
      for j:=1 to i-1 do
        if a[j] = 1 then inc(w);
      for j:=i+1 to n do
        if a[j] = 0 then inc(w);
      kq:=max(kq , n-w);
    end;
  write(kq);
end.


var
        a:Array[1..100] of longint;
        kq,n,max,min:longint;
procedure nhap;
var i:longint;
begin
        readln(n);
        max:=-high(longint);
        min:=high(longint);
        for i:=1 to n do
        begin
                read(a[i]);
                if a[i]>max then max:=a[i];
                if a[i]<min then min:=a[i];
        end;
end;
procedure giai;
var i,vt1,vt2,tam:longint;
begin
        for i:=1 to n do
                if a[i]=max then
                begin
                        vt1:=i;
                        break;
                end;
        for i:=1 to n do
                if a[i]=min then
                begin
                        vt2:=i;
                        break;
                end;
        if vt1>vt2 then
        begin
                tam:=vt1;vt1:=vt2;vt2:=tam;
        end;
        kq:=vt1;
        if n-vt1>kq then kq:=n-vt1;
        if vt2-1>kq then kq:=vt2-1;
end;
begin
        nhap;
        giai;
        write(kq);
        readln;
end.


var
  i,j,k,n,m,d,sum:longint;
  a:array[1..100] of integer;
begin
  readln(n,d);
  for i:=1 to n do read(a[i]);
  for i:=1 to n do
   for j:=i+1 to n do if a[i]>a[j] then begin
    k:=a[i];a[i]:=a[j];a[j]:=k;
   end;
  readln(m);
  if m<=n then begin
   for i:=1 to m do inc(sum,a[i]);
   writeln(sum);
  end
  else begin
   for i:=1 to n do inc(sum,a[i]);
   dec(sum,(m-n)*d);
   writeln(sum);
  end;
end.


var
    h,m:longint;
    s,s1,s2,s3,s4:string;
BEGIN
readln(s);
s1:=copy(s,1,2);
s2:=copy(s,4,2);
val(s1,h);
val(s2,m);
while (true) do
    begin
    inc(m);
    if (m=60) then
        begin
        inc(h);
        m:=0;
        end;
    if (h=24) then
        begin
        h:=0;
        m:=0;
        end;
    str(h,s1);
    str(m,s2);
    if (h<=9) then s1:='0'+s1;
    if (m<=9) then s2:='0'+s2;
    s3:=s1[2]+s1[1];
    s4:=s2[2]+s2[1];
    if (s1=s4)and(s2=s3) then
        begin
        writeln(s1,':',s2);
        break;
        end;
    end;
END.


var j,q,n,m,i,ans,s:longint;
a,b:array[0..100]of longint;
 begin
  read(n,m);
  for i:=1 to m do
    read(a[i],b[i]);

  for i:=1 to m-1 do
    for j:=i+1 to m do
      if b[i]<b[j] then
        begin
         q:=a[i];
         a[i]:=a[j];
         a[j]:=q;

         q:=b[i];
         b[i]:=b[j];
         b[j]:=q;
        end;

  i:=1;
  s:=0;
  ans:=0;
  while (i<=m)and(s<n) do
    begin
     if s+a[i]>n then
       begin
        ans:=ans+(n-s)*b[i];
        s:=n;
       end
     else
       begin
        ans:=ans+a[i]*b[i];
        s:=s+a[i];
       end;
     i:=i+1;
    end;
  writeln(ans);
 end.


 type mas = record
             x,y,c,p:longint;
            end;
 var i,j,k,n,m,p:longint;
  a:array [0..101] of mas;
  b:array [0..101] of longint;
 begin
{  assign (input,'input.txt');
  reset (input);
  assign (output,'output.txt');
  rewrite (output);  }
   read (n,m);

  for i:=1 to m do
   begin
    read (a[i].x,a[i].y,a[i].c);
    a[i].p:=i;
  end;

 for i:=1 to n do
  begin
   p:=20000;
   k:=0;
  for j:=1 to m do
    begin
     if a[j].x<=i then
      begin
      if a[j].y=i then
       if a[j].c<>0 then
        begin
         writeln (-1);
         halt;
        end
         else
        begin
         inc (a[k].c);
         k:=m+1;
         p:=-1;
        end;

      if (a[j].c<>0) and (a[j].y-i-a[j].c<p) then
       begin
        inc (a[k].c);
        k:=a[j].p;
        p:=a[j].y-i-a[j].c;
        dec (a[j].c);
       end;

      end;
    end;

   b[i]:=k;

  end;

  for i:=1 to n do
   write (b[i],' ');

  end.


Var f:Text;
    n,m,x,y,a,b:longint;

Function min(x,y:Longint):Longint;
Begin
    If x<y then Exit(x)
    else Exit(y);
End;

Procedure xl;
Var t1,t2,kq,tmp:Longint;
Begin
    Assign(f,'');
    Reset(f);
    Readln(f,m,n,x,y,a,b);
    Close(f);
    t1:=x-1;
    t2:=y-1;
    If ((x=1) and (y=1)) or ((x=1) and (y=n)) or ((x=m) and (y=1)) or ((x=m) and (y=n)) then kq:=0
    Else kq:=1000000000;
    If ((x-1>=a) or (m-x>=a)) and ((y-1>=b) or (n-y>=b)) then
     Begin
    If (t1 mod a=0) and (t2 mod b=0) then
     Begin
      t1:=t1 div a;
      t2:=t2 div b;
      If abs(t1-t2) mod 2=0 then
       Begin
        tmp:=min(t1,t2)+(abs(t1-t2));
        If (tmp<kq) then kq:=tmp;
       End;
     End;
    t1:=x-1;
    t2:=n-y;
    If (t1 mod a=0) and (t2 mod b=0) then
     Begin
      t1:=t1 div a;
      t2:=t2 div b;
      If abs(t1-t2) mod 2=0 then
       Begin
        tmp:=min(t1,t2)+(abs(t1-t2));
        If tmp<kq then
          kq:=tmp;
       End;
     End;
    t1:=m-x;
    t2:=y-1;
    If (t1 mod a=0) and (t2 mod b=0) then
     Begin
      t1:=t1 div a;
      t2:=t2 div b;
      If abs(t1-t2) mod 2=0 then
       Begin
        tmp:=min(t1,t2)+(abs(t1-t2));
        If tmp<kq then kq:=tmp;
       End;
     End;
    t1:=m-x;
    t2:=n-y;
    If (t1 mod a=0) and (t2 mod b=0) then
     Begin
      t1:=t1 div a;
      t2:=t2 div b;
      If abs(t1-t2) mod 2=0 then
       Begin
        tmp:=min(t1,t2)+(abs(t1-t2));
        If tmp<kq then kq:=tmp;
       End;
     End;
     End;
    If kq=1000000000 then Writeln('Poor Inna and pony!')
    Else Writeln(kq);
End;

Begin
    xl;
End.


program zadacha221b;
var x,i,k:longint;

function proverka(x,i:longint):integer;
var a:array[1..10] of byte;
    b:array[1..10] of byte;
    j,l:longint;
begin
proverka:=0;
j:=1;
while x>0 do
 begin
 a[j]:=x mod 10;
 x:=x div 10;
 inc(j);
 end;
l:=1;
while i>0 do
 begin
 b[l]:=i mod 10;
 i:=i div 10;
 inc(l);
 end;
for x:=1 to j-1 do
 for i:=1 to l-1 do
  if a[x]=b[i] then
   begin
   proverka:=1;
   exit;
   end;
end;
begin
{assign(input,'input.txt');
 assign(output,'output.txt');
 reset(input); rewrite(output);}
readln(x); k:=0;
for i:=1 to trunc(sqrt(x)) do
 if x mod i=0 then
  begin
  if proverka(x,i)=1 then inc(k);
  if (proverka(x,x div i)=1) and (i<>x div i) then inc(k);
  end;
{i:= x div 2;
if proverka(x,i)=1 then inc(k);
if x>1 then inc(k);}
write(k);
{close(input); close(output);}
end.


VAR N,M,K,t,X,Y,M1:int64;
begin
readln(N,M,K);
if K<N then begin
  writeln(1+K,' 1');
  halt;
end;
K:=K-N;
M1:=M-1;
t:=K div M1;
K:=K mod M1;
X:=N-t;
if X mod 2 = 1 then Y:=M-K
               else Y:=2+K;
writeln(X,' ',Y);
end.


const maxn = 105; mo = 1000003;
type matrix = array[0..maxn,0..maxn] of int64;
var c,w,h,ans:int64;
    tmp,a:matrix;
procedure multi(a,b:matrix; var c:matrix);
  var t:matrix;
      i,j,k:longint;
  begin
    fillchar(t,sizeof(t),0);
    for k:=0 to w do
      for i:=0 to w do
        for j:=0 to w do t[i,j]:=(t[i,j]+a[i,k]*b[k,j]) mod mo;
    for i:=0 to w do
      for j:=0 to w do c[i,j]:=t[i,j];
  end;
procedure init();
  var i:longint;
  begin
    readln(c,w,h);
    fillchar(tmp,sizeof(tmp),0);
    for i:=0 to w do tmp[i,i]:=1;
    fillchar(a,sizeof(a),0);
    a[0,0]:=1;
    for i:=1 to w do a[0,i]:=(a[0,i-1]*h) mod mo;
    for i:=1 to w do a[i,i-1]:=1;
  end;
procedure main();
  var i,j,k:longint;
  begin
    i:=c+1;
    while (i<>0) do begin
      if (i mod 2=1) then multi(a,tmp,tmp);
      multi(a,a,a); i:=i div 2;
{      for j:=0 to w do begin
        for k:=0 to w do write(tmp[j,k],' '); writeln;
      end;}
    end;
    writeln(tmp[0,0]);
  end;
begin
  init();
  main();
end.


{$mode delphi}

{ $DEFINE IS_TEST}

{$ifndef IS_TEST}
  uses sysutils;
{$endif}

procedure start;
begin
{$ifdef IS_TEST}
  assign(input, 'input.txt');
  reset(input);
{$endif}
end;

var
  a, b, s, r: integer;
begin
  start;

  read(a, b);

  s := a;

  while a div b <> 0 do begin
    inc(s, a div b);

    a := a div b + (a mod b);
  end;

  writeln(s);
end.


{ Free Pascal }
var step: array [1 .. 50] of qword;
    k: qword;
    n, i: byte;
    c: char;

begin
   k:= 0;

   readln(n);

   step[1]:= 1;
   for i:= 2 to n do
      step[i]:= step[i - 1] * 2;

   for i:= 1 to n do
   begin
      read(c);
      if(c = 'B') then
         k:= k + step[i];
   end;

   writeln(k);
end.