var
  c, v0, v1, a, l, i, j, sum, n, k, t, z: longint;

begin
  readln(c, v0, v1, a, l);
  sum := 0;
  t := l;
  repeat
    begin
      if sum >= c then
      begin
        writeln(k);
        exit;
      end;
      if v0 >= v1 then
      begin
        v0 := v1;
        a := 0;
      end;

      if l >= v0 then
      begin
        l := v0;
      end
      else
        l := t;
      if z = 0 then
      begin
        sum := sum + v0;
        v0 := v0 + a;
        inc(k);
        inc(z);
      end
      else
      begin
        if l > sum then
        sum := 0
        else
        sum := sum - l;

        sum := sum + v0;
        v0 := v0 + a;
        inc(k);
        inc(z);
      end;
    end;
  until sum >= c;
  writeln(k);
end.


Program z1;
var n,i,q,l:longint;
begin
read(n);
i:=0;
while n>0 do
begin
i:=i+1;
q:=i;
while q<>0 do
begin
l:=l+q mod 10;
q:=q div 10;
end;
if l=10 then n:=n-1;
l:=0;
end;
write(i);
end.


uses math;
var n,m,k,res,r,l,s:int64;
i:longint;
function f(x:int64):longint;
var sum:int64;
begin
    sum:=0;
    for i:=1 to n do
    begin
         sum:=sum+min(x div i,m);
    end;
    if sum<k then f:=0
    else f:=1;
end;
begin
read(n,m,k);
l:=0;
r:=n*m+1;
while l+1<r do
begin
    s:=(l+r) div 2;
    if f(s)=1 then r:=s
    else l:=s;
end;
writeln(r);
end.


const fi = '';
      fo = '';
      md = 1000000007;
var x, y, n: int64;
function modthoi(a: int64): int64;
begin
  while a < 0 do a:=a + md;
  exit(a mod md);
end;

begin
  assign(input,fi);     reset(input);
  assign(output,fo);      rewrite(output);

  readln(x,y);
  readln(n);
  if n mod 6 = 1 then write(modthoi(x))
  else if n mod 6 = 2 then write(modthoi(y))
  else if n mod 6 = 3 then write(modthoi(y-x))
  else if n mod 6 = 4 then write(modthoi(-x))
  else if n mod 6 = 5 then write(modthoi(-y))
  else write(modthoi(x-y));

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


{$R+ Q+ I+}
{$APPTYPE CONSOLE}
uses
  Sysutils;
var
    status : array [-100..100,-100..100] of boolean;
    ch : char;
    x,y,t : integer;
begin
    x := 0;
    y := 0;
    status[x][y] := true;
    while not eoln do begin
          read(ch);
          if ch = 'L' then dec(x);
          if ch = 'R' then inc(x);
          if ch = 'U' then inc(y);
          if ch = 'D' then dec(y);
          t := -1;
          if status[x][y-1] = true then inc(t);
          if status[x][y+1] = true then inc(t);
          if status[x-1][y] = true then inc(t);
          if status[x+1][y] = true then inc(t);
          if (t > 0) or (status[x][y] = true) then begin
             write('BUG');
             halt;
          end;
          status[x][y] := true;
    end;
    write('OK');
end.


var
sum,n,a,b,i: integer;
arr: array[1..20] of integer;
begin
read(n,a,b);
for n:=1 to n do
read(arr[n]);
for i:=1 to n div 2 do
begin
if arr[i]=2 then if arr[n-i+1] = 2 then if a<b then sum:=sum+a+a else sum:=sum+b+b else if arr[n-i+1]=1 then sum:=sum+b else sum:=sum+a;
if arr[i]=1 then if arr[n-i+1] = 2 then sum:=sum+b else if arr[n-i+1] = 0 then begin writeln(-1); halt; end;
if arr[i]=0 then if arr[n-i+1] = 2 then sum:=sum+a else if arr[n-i+1] = 1 then begin writeln(-1); halt; end;

end;
if n mod 2 = 1 then if arr[n div 2 + 1] = 2 then if a<b then sum:=sum+a else sum:=sum+b;
writeln(sum);
end.


{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}
const LESS = -1; EQUAL = 0; MORE = 1;
type TMult = record
               kind,num,expid: longint;
             end;
     TProd = record
               sign: boolean;
               cm: longint;
               sn: array [0..110] of boolean;
               m: array [0..110] of TMult;
             end;
     TExpr = record
               cp: longint;
               p: array [0..110] of TProd;
             end;
var
  sl,st: ansistring;
  z,mm,ps,pz,need,ans,kc,i,n: longint;
  left,right,sign,return: array [0..1010] of longint;
  f: array [0..33333] of longint;
  c: array [0..1010] of char;
  exp: array [0..110] of TExpr;
  ch: char;
  can: boolean;

function makeexpr(s:ansistring):longint;
var
  m,q,i,v,t,bal: longint;
  ss: ansistring;
begin
  inc(mm); m:=mm;
  exp[m].cp:=0;
  s:='+'+s+'+';
  i:=1;
  while i < length(s) do
  begin
    inc(exp[m].cp);
    v:=exp[m].cp;
    exp[m].p[v].sign:=s[i] = '-';
    exp[m].p[v].cm:=0;
    s[i]:='*';
    while (s[i] = '*') or (s[i] = '/') do
    begin
      inc(exp[m].p[v].cm);
      t:=exp[m].p[v].cm;
      exp[m].p[v].sn[t]:=s[i] = '/';
      if s[i+1] = 'n' then
      begin
        exp[m].p[v].m[t].kind:=1;
        inc(i,2);
      end else
      if s[i+1] = 'f' then
      begin
        exp[m].p[v].m[t].kind:=3;
        ss:=''; bal:=1;
        inc(i,3);
        while bal > 0 do
        begin
          if s[i] = '(' then inc(bal) else
          if s[i] = ')' then dec(bal);
          if bal = 0 then break;
          ss:=ss+s[i];
          inc(i);
        end;
        exp[m].p[v].m[t].expid:=makeexpr(ss);
        inc(i);
      end else
      begin
        exp[m].p[v].m[t].kind:=2;
        q:=0; inc(i);
        while s[i] in ['0'..'9'] do
        begin
          q:=q*10+Ord(s[i])-48;
          inc(i);
        end;
        exp[m].p[v].m[t].num:=q;
      end;
    end;
  end;
  makeexpr:=m;
end;

function eval(m,z:longint):longint;
var
  res,i,j,cur,v: longint;
begin
  res:=0;
  for i:=1 to exp[m].cp do
  begin
    cur:=1;
    for j:=1 to exp[m].p[i].cm do
    begin
      if exp[m].p[i].m[j].kind = 1 then v:=z else
      if exp[m].p[i].m[j].kind = 2 then v:=exp[m].p[i].m[j].num
      else v:=f[eval(exp[m].p[i].m[j].expid,z)];
      if exp[m].p[i].sn[j] then cur:=cur div v
      else cur:=(cur*v) mod 32768;
    end;
    if exp[m].p[i].sign then cur:=-cur;
    inc(res,cur);
    if res >= 32768 then dec(res,32768);
    if res < 0 then inc(res,32768);
  end;
  eval:=res;
end;

function get(z:longint):longint;
var
  i,zleft,zright: longint;
begin
  for i:=1 to n do
  begin
    zleft:=eval(left[i],z);
    zright:=eval(right[i],z);
    if (sign[i] = LESS)  and (zleft < zright) or
       (sign[i] = EQUAL) and (zleft = zright) or
       (sign[i] = MORE)  and (zleft > zright) then
    begin
      get:=eval(return[i],z);
      exit;
    end;
  end;
  get:=0;
end;

begin
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  read(need);
  kc:=0; can:=False;
  while not eof(input) do
  begin
    read(ch);
    if (ch = ' ') or (ch = #9) or (ch = #13) or (ch = #10) then continue;
    if ch = '{' then can:=True else
    if ch = '}' then can:=False else
    if can then
    begin
      inc(kc);
      c[kc]:=ch;
    end;
  end;
  sl:=''; n:=0;
  mm:=1;
  exp[1].cp:=1;
  exp[1].p[1].sign:=False;
  exp[1].p[1].cm:=1;
  exp[1].p[1].m[1].kind:=2;
  exp[1].p[1].m[1].num:=0;
  for i:=1 to kc do
    if c[i] = ';' then
    begin
      inc(n);
      ps:=Pos('r',sl);
      if ps = 1 then
      begin
        left[n]:=1;
        right[n]:=1;
        sign[n]:=EQUAL;
      end else
      begin
        st:=Copy(sl,4,ps-5);
        pz:=Pos('<',st);
        if pz > 0 then sign[n]:=LESS else
        begin
          pz:=Pos('>',st);
          if pz > 0 then sign[n]:=MORE else
          begin
            pz:=Pos('=',st);
            Delete(st,pz,1);
            sign[n]:=EQUAL;
          end;
        end;
        left[n]:=makeexpr(Copy(st,1,pz-1));
        right[n]:=makeexpr(Copy(st,pz+1,1000));
        Delete(sl,1,ps-1);
      end;
      return[n]:=makeexpr(Copy(sl,7,1000));
      sl:='';
    end
    else sl:=sl+c[i];
  ans:=-1;
  for z:=0 to 32767 do
  begin
    f[z]:=get(z);
    if f[z] = need then ans:=z;
  end;
  writeln(ans);
  close(input);
  close(output);
end.


var st,l,r:int64;
s:string;

function f(x:int64):int64;
var ans,l,y:int64;
j,i,xx,yy:longint;
ss:string;
 begin
  if x<=9 then  begin
                  f:=x;
                  exit;
                end;

  ans:=0;l:=1;
  str(x,s);
  for i:=1 to length(s)-1 do
   begin
      ans:=ans+9*l;
      if i<>1 then l:=l*10;
   end;
  val(s[1],xx,yy);
  ans:=ans+(xx-1)*(l) ;
  y:=0;
  for i:=2 to length(s)-1 do
    y:=y*10+ord(s[i])-48;
 // val(ss,y,xx);
  ans:=ans+y;
  if s[1]<=s[length(s)] then inc(ans);

  f:=ans;
 end;

 begin
  readln(l,r);
  writeln(f(r)-f(l-1));
 end.


program probe;
var
	n,i,j,k,l,last,count,x,tx,kk,p,tlast,sum,up,tl:longint;
	f:array[0..209,0..309,0..1,0..255] of double;
	ans:double;
function min(a,b:longint):longint;
	begin
		if a<b then exit(a) else exit(b);
	end;
procedure delta(i,j,k,l:longint; num:double);
	begin
		f[i,j,k,l]:=f[i,j,k,l]+num;
	end;
begin
	readln(x,kk,p);
	count:=0; tx:=x; last:=x mod 256; x:=x div 256;
	if x=0 then f[0,300,0,last]:=1
	else begin
		tlast:=x mod 2; sum:=0;
		while (x<>0)and(x mod 2=tlast) do begin
			x:=x shr 1;
			inc(sum);
		end;
		f[0,sum,tlast,last]:=1;
	end;
	for i:=0 to kk-1 do
		for j:=0 to 309 do
			for k:=0 to 1 do
				for l:=0 to 255 do begin
					if l and (1 shl 7)<>0 then up:=1 else up:=0;
					if k=up then delta(i+1,min(300,j+1),k,(l mod 128)*2,f[i,j,k,l]*p/100)
					else delta(i+1,1,up,(l mod 128)*2,f[i,j,k,l]*p/100);
					if l<255 then delta(i+1,j,k,l+1,f[i,j,k,l]*(1-p/100))
					else if k=0 then delta(i+1,1,1,0,f[i,j,k,l]*(1-p/100))
					else delta(i+1,j,0,0,f[i,j,k,l]*(1-p/100));
				end;
	ans:=0;
	for j:=0 to 309 do begin
		for k:=0 to 1 do begin
			for l:=0 to 255 do begin
				if l=0 then begin
					if k=0 then sum:=8+j else sum:=8;
					ans:=ans+sum*f[kk,j,k,l];
				end else begin
					sum:=0; tl:=l;
					while (tl mod 2=0) do begin
						inc(sum); tl:=tl shr 1;
					end;
					ans:=ans+sum*f[kk,j,k,l];
				end;
			end;
		end;
	end;
	writeln(ans:0:9);
end.


var i,j,k,l,m,n:longint;
    s,logs,temp,temp2,ans,ss,temp3,temp4,x,now,tt,one:int64;
    num:array[0..100]of int64;
    dp:array[0..150,-1..150,0..1]of int64;//
function bis2(l,r:int64):int64;
var mid:int64;
begin
    if l=r then exit(l);
    mid:=(l+r)>>1;
    if mid<<(i+1)-mid>s then exit(bis2(l,mid)) else exit(bis2(mid+1,r));
end;
function bis(l,r:int64):int64;
var mid:int64;
begin
    if l=r then exit(l);
    mid:=(l+r)>>1;
    if (mid<<(i+1)+(mid<<1+1)<<j-mid-(mid<<1+1)>s) then exit(bis(l,mid)) else exit(bis(mid+1,r));
end;
function min(a,b:int64):int64;
begin
    if a<b then exit(a) else exit(b);
end;
function max(a,b:int64):int64;
begin
    if a<b then exit(b) else exit(a);
end;
begin
    one:=1;
    readln(s);
    ss:=1;
    while ss<s do begin
        ss:=ss<<1;
        inc(logs);
    end;
    //logs:=logs+10;
    inc(logs);
    for i:=1 to logs do begin
        for j:=1 to logs do begin
            temp:=bis(0,s>>(max(i,j))+1)-1;
            if temp>0 then begin
                temp2:=s-(temp<<(i+1)+((temp<<1)or 1)<<j-temp-((temp<<1)or 1));
                for k:=0 to i+j-2 do begin
                    tt:=temp2+k;
                    now:=0;
                    x:=0;
                    for l:=1 to logs do if (now or (one<<(logs-l)))<=tt then begin
                       num[l]:=1;
                       now:=now or (one<<(logs-l));
                       inc(x);
                    end else num[l]:=0;
                    {if (i=3) and (j=5) and (k=5)then begin
                       writeln('x=',x,' k=',k);

                    end;}
                    if (num[logs]=1) or (x>k) then continue;
                    dp[0,0,0]:=1;
                    for l:=1 to logs-1 do begin
                        if l>=logs-min(i,j)+1 then begin
                          if num[l]=1 then begin
                              for m:=0 to k-x do begin
                                  dp[l,m,0]:=2*dp[l-1,m,0];
                                  dp[l,m,1]:=dp[l-1,m-1,0]+dp[l-1,m-1,1];
                              end;
                          end else begin
                              for m:=0 to k-x do begin
                                  dp[l,m,0]:=dp[l-1,m,0]+dp[l-1,m,1];
                                  dp[l,m,1]:=2*dp[l-1,m-1,1];
                              end;
                          end;
                        end else if l<=logs-max(i,j) then begin
                            if num[l]=1 then begin
                                for m:=0 to k-x do begin
                                    dp[l,m,0]:=0;
                                    dp[l,m,1]:=dp[l-1,m-1,0];
                                end;
                            end else begin
                                for m:=0 to k-x do begin
                                    dp[l,m,0]:=dp[l-1,m,0];
                                    dp[l,m,1]:=0;
                                end;

                            end;
                        end else begin
                            if num[l]=1 then begin
                                for m:=0 to k-x do begin
                                    dp[l,m,0]:=dp[l-1,m,0];
                                    dp[l,m,1]:=dp[l-1,m-1,0];
                                end;
                            end else begin
                                for m:=0 to k-x do begin
                                    dp[l,m,0]:=dp[l-1,m,0];
                                    dp[l,m,1]:=dp[l-1,m-1,1];
                                end;
                                //dp[l,0,0]:=1;
                            end;
                        end;
                    end;  //maybe l>i or l>j;
                    {if (i=3) and (j=5) and(k=5) then begin
                        writeln('x=',x,' dp=',dp[logs-1,k-x,0]);
                    end;                }
                    ans:=ans+dp[logs-1,k-x,0];
                    {if dp[logs-1,k-x,0]>0 then begin
                        writeln('i=',i,' j=',j,' k=',k,' temp2=',temp2,' temp=',temp,' dp=',dp[logs-1,k-x,0]);
                    end;                      }
                end;
            end;
        end;
    end;
    for i:=1 to logs do begin
        temp:=bis2(0,s>>i+1)-1;
        if temp>0 then begin
            temp2:=s-(temp<<(i+1)-temp);
            for j:=i downto 1 do begin
                if temp2>=one<<j-1 then temp2:=temp2-((one<<j)-1);
            end;
            if temp2=0 then inc(ans);
        end;
    end;

    writeln(ans+1);
end.


var
  i,j : longint;
  ans,sum,n,m,k : int64;
  a,a1 : array[1..101] of int64;
procedure sort(l,r : longint);
var
  a1,y1 : int64;
  i,j,m : longint;
begin
  i := l;
  j := r;
  m := round((i+j)/2);
  a1 := a[m];
  repeat
    while (a[i] < a1) do inc(i);
    while (a[j] > a1) do dec(j);
    if (i <= j) then
    begin
      y1 := a[i];
      a[i] := a[j];
      a[j] := y1;
      inc(i);
      dec(j);
    end;
  until (i > j);
  if (l < j) then sort(l,j);
  if (i < r) then sort(i,r);
end;
begin
  readln(n,m);
  for i := 1 to n do
  begin
    read(a[i]);
    a1[i] := a[i];
  end;
  write(0,' ');
  for i := 2 to n do
  begin
    sum := 0;
    for j := 1 to i do
      sum := sum+a[j];
    sort(1,i-1);
    for j := i-1 downto 1 do
      if (sum > m) then
      begin
        inc(ans);
        dec(sum,a[j]);
      end;
    write(ans,' ');
    ans := 0;
    for j := 1 to i do
      a[i] := a1[i];
  end;
end.


var a,b,x,c,d,cnt:integer;
function chek( a:integer):boolean;
var b,c:integer;
var n:boolean;
begin
b:=a;
n:=false;
while(b>0) do begin
if(b mod 10=7) then begin
n:=true;
break;
end;
b:=b div 10;
end;
if(n) then
chek:=true
else
chek:=false;
end;

begin
readln(x);
read(a,b);
while not (chek(a) or chek(b)) do begin
b:=b-x;
cnt:=cnt+1;
if(b<0) then begin
b:=60+b;
a:=a-1;
if(a<0) then
a:=24+a;
end;
end;
writeln(cnt);
end.


var s:string;n,i,sa,k:integer;
begin read(s);sa:=0;k:=0;
for i:=1 to length(s) do if s[i]='a' then sa:=sa+1 else k:=k+1;
if sa>k then write(length(s))
else write(2*sa-1)
end.


                          const eps=1e-12;
                      besk=2002000000000000000; label 4,1,3,2,44;
                type mas=array[-100..1200000+1] of int64;
                integer=longint;    zap=record p1,p2,p3:int64; end;
                zap1=^zap;
                var qq,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,ll,rr,bet,al:extended;
                ot1,ot2:zap;
                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,m,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;
                  invx,invy,summ,place,kol,str,b2,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean;  pl:longint;
                 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;
                  zpl,zmi,path,lx,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;
                  ppole:array[-1000000..3000000] of char;
                  stroka:array[-1000..1000000] of char;
                  t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;
                  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,dd,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,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;
                  ddd: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;

                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;

 begin
  {  assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
   }
    {  read(p,tt);
      for i:=1 to p do read(a[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 write(a[i],' '); writeln;
      x[1]:=0;
      for i:=2 to p do x[i]:=x[i-1]+(a[i]-a[i-1])*(i-1);
      for i:=1 to p do write(x[i],' '); writeln;
      y[p]:=0;
      for i:=p-1 downto 1 do y[i]:=y[i+1]+(a[i+1]-a[i])*(p-i);
      for i:=1 to p do write(y[i],' '); writeln;

      goto 1;
     }
     read(n,cc,aa,bb);
     for i:=0 to 100000 do
       begin
          t:=bb*i;
          if ((cc-t) mod aa=0)and(cc-t>=0) then
          begin flag:=true; t2:=i; t1:=(cc-t) div aa; break;  end;

       end;

    if not flag  then begin writeln(-1); goto 1;   end;
    if n>=(t1+t2) then writeln(t1,' ',t2,' ',n-t1-t2) else write(-1);

      1: close (output);
    end.


program C268;
const
	Inp = '';
	Oup = '';
var
	Sum,Modul,K:int64;
	M:int64;

procedure Main();
begin
	assign(input,inp); reset(input);
	assign(output,oup); rewrite(output);
	readln(M);
        K:=10000000000000000;
	Sum:=45*17;
        Sum:=Sum*K;
        Sum:=Sum+1;
	Modul:=Sum mod M;
	writeln(M-Modul+1,' ',M-Modul+K*10);
end;

begin
	Main();
end.


var l,d,v,g,r,vr,vrr,er:extended;
begin
readln(l,d,v,g,r);
vr:=d/v;vrr:=vr-trunc(vr/(g+r))*(g+r);
if vrr<g then er:=0 else er:=(g+r)-vrr;
writeln((l-d)/v+vr+er:0:6);
end.


var
  s,s2:string;
  i,sum:longint;
begin
  readln(s);
  for i:=1 to length(s) do
    if (s[i]>='A')and(s[i]<='Z') then sum:=sum+1;
  if sum<=length(s) div 2 then
  begin
    for i:=1 to length(s) do
      if (s[i]>='A')and(s[i]<='Z') then s2:=s2+chr(ord(s[i])+32)
      else s2:=s2+s[i];
  end
  else
  begin
    for i:=1 to length(s) do
      if (s[i]>='A')and(s[i]<='Z') then s2:=s2+s[i]
      else s2:=s2+chr(ord(s[i])-32);
  end;
  writeln(s2);
end.


var a, b, c, n, k, l, i, h, q
:LongInt;
     s, r, t:String;
 Begin
   ReadLn(s);
   ReadLn(n);
    r:=s[1]+s[2];
     Val(r, a);
 t:=s[4]+s[5];
   Val(t, b);
   h:=a*60+b+n;
    k:=h mod 60;
   q:=h div 60  mod 24;
   if q=24 then q:=0;
   if (q<10) then Write('0',q,':')
   else Write(q,':');
   if k<10 then Write('0',k)
   else Write(k);
  // Write(h div 60 mod 24,':',k);

 End.


begin
    var a: array[1..30] of char :=
    ('q', 'w', 'e', 'r', 't',
    'y', 'u', 'i', 'o', 'p', 'a',
    's', 'd', 'f', 'g', 'h', 'j', 'k',
    'l', ';', 'z', 'x', 'c', 'v', 'b',
    'n', 'm', ',', '.', '/');
    var a1 := ReadString;
    var b := ReadString;
    for var i := 1 to b.Length do
    begin
        for var j := 1 to 30 do
        begin
            if(b[i] = a[j]) then begin
                if(a1 = 'R') then begin
                    if(b[i] = 'q') then
                        b[i] := a[30] else b[i] := a[j - 1];
                        break;
                end else begin
                    if(b[i] = '/') then
                        b[i] := a[1] else b[i] := a[j + 1];
                        break;
                end;
            end;
        end;
    end;
    writeln(b);
end.


program azbuka;
var
i,o:string;
j:longint;
begin
readln(i);

while length(i)<>0 do
  begin
  if i[1]='.'
      then
      begin
      o:=o+'0';
      delete(i,1,1);
      end
        else
          begin
           if i[2]='.' then
                        begin
                        o:=o+'1';
                        delete(i,1,2);
                        end
                          else
                          begin
                          o:=o+'2';
                          delete(i,1,2);
                          end;
           end;
  end;

writeln(o);
end.


var
  a: string;
  b : int64;
  i : longint;
begin

 read(a);
 if (a[1] >='5')and(a[1]<>'9') then a[1] := chr(57 - ord(a[1]) + 48);
 for i := 2 to length(a) do
 if a[i] >='5' then a[i] := chr(57 - ord(a[i]) + 48);
 writeln(a);
end.


var
n,m,k,r,d:longint;
s:char;
begin
readln (n,m,k);

if k mod (2*m)=0 then
  begin
  r:=k div (2*m);
  d:=m;
  s:='R';
  end

  else begin
  r:=(k div (2*m))+1;
  k:=k mod (2*m);
  if k mod 2=0 then
    begin
    d:=k div 2;
    s:='R';
    end
    else begin
    d:=(k div 2)+1;
    s:='L';
    end;
  end;

writeln (r,' ',d,' ',s);
end.


Var
  s1,s2,s3 : string;
Begin
  Readln(s1);
  Readln(s2);
  Readln(s3);
  If ((s1<>s2) and (s2<>s3) and (s1<>s3)) or ((s1=s2) and (s2=s3)) then Writeln('?') else

  If s1=s2 then
  Begin
    If s1='rock' then
     Begin
      If s3='paper' then Writeln('S') else
      If s3='scissors' then Writeln('?')
     End         else
    If s1='paper' then
     Begin
      If s3='rock' then Writeln('?') else
      If s3='scissors' then Writeln('S')
     End          else
    If s1='scissors' then
     Begin
      If s3='rock' then Writeln('S') else
      If s3='paper' then Writeln('?')
     End
  End     else

  If s1=s3 then
  Begin
    If s1='rock' then
     Begin
      If s2='paper' then Writeln('M') else
      If s2='scissors' then Writeln('?')
     End         else
    If s1='paper' then
     Begin
      If s2='rock' then Writeln('?') else
      If s2='scissors' then Writeln('M')
     End          else
    If s1='scissors' then
     Begin
      If s2='rock' then Writeln('M') else
      If s2='paper' then Writeln('?')
     End
  End     else

  If s2=s3 then
  Begin
    If s2='rock' then
     Begin
      If s1='paper' then Writeln('F') else
      If s1='scissors' then Writeln('?')
     End         else
    If s2='paper' then
     Begin
      If s1='rock' then Writeln('?') else
      If s1='scissors' then Writeln('F')
     End          else
    If s2='scissors' then
     Begin
      If s1='rock' then Writeln('F') else
      If s1='paper' then Writeln('?')
     End
  End
End.


var s,tg:int64;
    a,b:longint;

BEGIN
    readln(a,b,s);
    tg:=s-abs(a)-abs(b);
    if (tg>=0) and (tg mod 2=0) then writeln('YES')
    else writeln('NO');
END.


                           const eps=0.0000000001;  besk1=200000008;  nnn=4600000;
            besk=80000000000000000;
              modul=1000000007{998244353};

   label 22,1,2,3,4,33;
    type    real=extended;   double=extended;
    mas=array [-300000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3,p4 :int64;end; zap1=^zap;
    mass=array[-10000..nnn] of longint;mass1=^mass;
    matr=array[-10..200,-10..200] of int64;
    matr1=^matr;
    var p01,hh,oldq,ll,rr,maskk,otmin,otmax,izb,kol,oldpp,t,pos1,pos2,r,razm,kollad,leftx,rightx,lefty,righty,num,dirx,diry,oldii,obr,koludal,maxdl,mindl,tmin,aaa,bbb,ccc,kolst,kollek,aa,bb,t1,t2,kolx,koly,ans,ans2,dl,posleft,posright,n,xxx,yyy,dx,dy,m,w,h,jjj,l,cc,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,j2,ttt,ppp,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,posx,posy,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,p0,jj,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,nm,smin,cen:int64;
   istart,jstart,ifinish,jfinish,k,i2,i3,step2,k1,k2,pp0,mask,i1,j1,step1, step, i,j:longint;
   maxprefix,maxsuffix,prefix,suffix,minprefix,minsuffix,zagr,xx,yy,kolizm,test,zz,predok,hesh,yold,x1,x0,d,b,a,zsum,y,x,z:array[-200000..1535002] of int64;
    otmat,amat,bmat,cmat:matr;
    zan1,zan2:array[-1000..200000,-2..26] of boolean;
    marked1,marked2:array[-2000..2000000] of boolean;
   gr1,gr2,gr:array[-1..2000,-1..2000] of boolean;
    dd,ddr:array[-1..1502,-1..1502] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;  anss:zap;
    sss,ss,ss1,ss2:string;
    newstr,str:array[-1000..200000] of string;
    lll,rrr,v,dist,alpha,phi:extended;
    masmatr:array[-1..101,-1..101,-1..101] of int64;
    zzz,ddnew,koef,polex,ddsum,ddl:array[-1..4,-1..1300000] of int64;
    str1,str2,dpos,sum,ppos,mma,ma:array[-1000..200005,-1..30] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..20] of longint;
    z0,y1,z1,z2,kolnul,fact,next,prev,s,name,dnew, voltay,c,day:mas;
    zzzz:array[0..125000000] of byte;
    aaaa,bbbb,x2:extended;
    delit:array[0..100000,0..20] of longint;
    pole:array[-10..2002,-10..2005] of char;
    ddd,matrr,ppole,dd3,dd4:array[-10..2000,-10..2200] of int64;
    ddnnew:array[-1..12,-1..12,0..200,0..3] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    ssold,sss1,sss2:string;
    def,stepen,koled,och,newoch,place,newnabor,stoim,nabor:array[-10..500005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
     dost:array[-1..210,-1..210,0..3,0..3] of int64;
    sss12:string;ch,ch1,ch2:char;
    pr,heshh,numright,dr: array [-10..2060,-1..1600] of int64;
    s3,s2,s1:array[-100..500000] of string;

    grr :array [-10..2010,-10..2010] of extended;
    maxpr:array[0..nnn] of string;
     tx,ty,vel,ott,v0,v1,s0,t0:int64;
     zv:point;
     left,right,ugol,rot,temp,sumtemp,vol,newx,newy:array[-1000..400000] of int64;
     mash,sqx,sqy,ottt:extended;
     xxxx,yyyy,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;

procedure udal(p:longint);
begin  next[prev[p]]:=next[p]; prev[next[p]]:=prev[p]; 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 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:int64):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 begin fl:=false; break; end;

   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 gl(ch:char):boolean;
begin
 if (ch='o')or (ch='a')or(ch='e')or(ch='u')or(ch='i') then gl:=true else gl:=false;

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;

 function ff(gr:int64):boolean;

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

    end;
   writeln(' cc= ',cc);
   cc:=min(cc+3,m+1);
   repeat dec(cc) until y[cc]<=gr;
   if y[cc]=gr then fl:=true else fl:=false;
  ff:=fl;
end;

function dis(i,j:longint):longint;
begin
  dis:=min(abs(i-j),26-abs(i-j));

end;

function fg(t,t1,t2:int64):int64;
var tt,t3,p:int64;
begin
 if t1>t2 then begin  t3:=t1; t1:=t2; t2:=t3; end;
        if t2 mod t1=0 then begin fg:=0;  end
     else begin
    {  writeln('delim ',t);
    } p:=t2 mod t;

     if p=0 then fg:=0 else
     fg:=(t-p);
          end;
end;

function best(t1,t2:int64):int64;
var i,j:longint; ott,p1,p2,pp,p,t,ot:int64;
begin
ot:=1000000000000;
 for i:=0 to 1000 do
   begin
      p1:=t1+i;
      p2:=t2+i;
      p:=nod(p1,p2);
      pp:=(p1*p2) div p;
      if pp<ot then begin  ot:=pp; ott:=i; end;

   end;

best:=ott;
end;

begin
   { assign (input,'D:\Projects\input.txt');reset(input);
      assign (output,'D:\Projects\output.txt'); rewrite(output);
    }
     readln(t1,t2);
    { writeln(fg(t1,t2),' ',best(t1,t2));
     }

     {for i:=1 to 20 do for j:=i to 20 do writeln(i,' ',j,' ans= ',fg(i,j),' ',best(i,j));
      }

      if t1>t2 then begin  t:=t1; t1:=t2; t2:=t; end;
         t:=t2-t1;
     v:=t;
     v:=sqrt(v);
     for i:=1 to round(v) do if t mod i=0 then
     begin inc(q);x[q]:=i; inc(q); x[q]:=t div i;  end;
     { for i:=1 to q do write(x[i],' '); writeln;
     }      ot:=8000000000000000000;
     for i:=1 to q do
       begin
          t:=fg(x[i],t1,t2);
         { writeln('del= ',x[i],' dob= ',t);
         } p1:=t1+t; p2:=t2+t;
         { writeln('chisla= ',p1,' ',p2);
         } tt:=nod(p1,p2);
          tt:=(p1*p2) div tt;
          if tt<ot then begin ii:=x[i]; ot:=tt; end;
         { writeln('del= ',x[i],' nok= ',tt,' ot= ',ot); }
       end;

     { writeln('ot= ',fg(ii,t1,t2),' min nok= ',ot);
      }

      writeln(fg(ii,t1,t2));

1:             close(output);
end.


var n,k,q,i,j:LongInt;
      s:string;
begin
readln(n,k);
readln(s);
for i:=1 to n do
      begin
      for j:=i to n do
         if s[i]=s[j] then
                q+=1;
      if q>k then
         begin
         writeln('NO');
         halt;
         end;
      q:=0;
      end;
writeln('YES');
end.


var n,k,x:longint;
begin
        readln(n,k);
        x:=n div k;
        writeln((x+1)*k);
end.


var
  x:int64;
begin
  readln(x);
  while x mod 3=0 do x:=x div 3;
  writeln(x div 3+1);
end.


var
n,a:int64;
i:longint;
begin
readln(n);
a:=1;
for i:=1 to n+1 do a:=a*2;
writeln(a-2);
end.


const fi=''; fo=''; oo=maxlongint; maxn=100010;
var x,y,n,a,b:int64;
function cmp(x1,y1,x2,y2:int64):longint;
var d:int64;
begin
    d:=x1*y2-x2*y1;
    if d<0 then exit(-1);
    if d=0 then exit(0);
    exit(1);
end;
procedure solve;
var a1,k:int64; b1,d:longint;
begin
    a:=oo; b:=1;
    for b1:=1 to n do
    begin
        a1:=(x*b1)div y;
        d:=cmp(abs(x*int64(b1)-y*a1),abs(y*int64(b1)),abs(x*b-y*a),abs(y*b));
        if(d<0)or((d=0)and((b1<b)or((b1=b)and(a1<a))))then
        begin
            a:=a1;
            b:=b1;
        end;
        a1:=a1+1;
        d:=cmp(abs(x*int64(b1)-y*a1),abs(y*int64(b1)),abs(x*b-y*a),abs(y*b));
        if(d<0)or((d=0)and((b1<b)or((b1=b)and(a1<a))))then
        begin
            a:=a1;
            b:=b1;
        end;
    end;
end;
procedure process;
    procedure enter;
    begin
        assign(input,fi); reset(input);
        readln(x,y,n);
        close(input);
    end;
    procedure print_res;
    begin
        assign(output,fo); rewrite(output);
        writeln(a,'/',b);
        close(output);
    end;
begin
    randomize;
    enter;
    solve;
    print_res;
end;
begin process; end.


           const eps=1e-10;
      besk=8000000000000000000; label 1,3,2,44;
type mas=array[-1000000..2000000+1] of int64; integer=longint;
var i1,j1,ppp,tt,start,qq,kol1,dl,p0,p1,stepp,h,p2,n2,i,j,k,l,m,step,k1,w,mesto,num:longint;
ss,ss1:string;
hh,pos1,pos2,pp,ii,jj,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,sum,n1,t2,q,t,p:int64; flag1:boolean;
  a2,b2,last,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,lnew,rnew,rr,a,b,a1,b1:mas; flag2,flag:boolean;  pl:longint;
  gr,grr,ener,kol,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;
  zan:array[-10..1000000] of boolean;
  ot1,otmax,v:extended;
  sp,sss:array[-10..1000000] of string;
  newpole,newpole1,pole1,pole:array[100..1400,-1..1400] of int64;
  pos,ot:int64;
  ch:char;
  z,nomer,newplace,newstr,place,str,s,next,prev,xx,yy,aold,x,y:array[-100000..200000] of int64;
  dd:array[-10..5010,-10..5010] of int64;
 function srav(i,j:longint):boolean;
  begin if (a[i]<a[j])or(a[i]=a[j])and(a1[i]<a1[j])  then
  srav:=true else srav:=false; 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 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 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 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;

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;
       if y[cc]<=gr then aa:=cc else bb:=cc;

    end;
  { writeln(' cc= ',cc);
  } cc:=min(cc+3,p+1);
   repeat dec(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 vhodit(t:int64):boolean;
var sum,ii,jj,p:int64;  ans:boolean;
begin
   p:=t;
   for i:=1 to t do a[i]:=x[i];
    n:=1;
    repeat n:=n*2 until n>=p;
         for i:=p+1 to n+2 do a[i]:=besk;
        sort(a);
    { for i:=1 to p do write(a[i],' '); writeln;
     }
     sum:=0;
    if not odd(t) then
     for i:=1 to t div 2 do sum:=sum+a[2*i] else
     for i:=1 to (t+1) div 2 do sum:=sum+a[2*i-1];
    { writeln('sum= ',sum);
     }
 ans:=sum<=hh;
vhodit:=ans;
end;

begin

  { assign (input,'D:\Projects\input.txt');reset(input);
   assign (output,'D:\Projects\output.txt'); rewrite(output);
   }
   read(p1,p2);
   for i1:=0 to 30 do for j1:=0 to 19 do
     begin
       p:=1;
       for i:=1 to i1 do p:=p*2;
       for j:=1 to j1 do p:=p*3;
       inc(q);
       a[q]:=p;

     end;

   { for i:=1 to q do write(a[i],' ');
    writeln;  writeln;
   } n:=1; repeat n:=n*2; until n>=q;
    for i:=q+1 to n+2 do a[i]:=besk;
    sort(a);
  {    for i:=1 to q do write(a[i],' ');
    writeln;
  }  for i:=1 to q do if (a[i]>=p1)and(a[i]<=p2) then inc(ot);
    writeln(ot);

 1: close (output);
     end.


var n,m,t,i:longint;
a:array[0..100000]of longint;
begin
//assign(input,'c.in');reset(input);
//assign(output,'c.out');rewrite(output);
readln(n,m);
while m>0 do
  begin
  inc(t);
  a[t]:=m mod n;
  m:=m div n;
  end;
for i:=1 to t+100 do
  if(a[i]>=n)then
    begin
    a[i+1]:=a[i+1]+a[i] div n;
    a[i]:=a[i] mod n;
    end
  else
    if(a[i]<>0)and(a[i]<>1)and(a[i]<>n-1)then
      begin
      writeln('NO');
      close(input);close(output);halt;
      end
    else
      if a[i]=n-1 then inc(a[i+1]);
write('YES');
close(input);close(output);
end.


var
n,b,p,x,y,b1,i,j:integer;
begin
readln(n,b,p);
i:=n;
while i<>1 do
begin
j:=i div 2;
x:=x+j*(1+b*2);
i:=i-j;
end;
y:=n*p;
writeln(x,' ',y);
end.


var
 l,r,a,i:longint;
function min(x,y:longint):longint;
begin
 if x<y then exit(x) else exit(y);
end;
begin
 read(l,r,a);
 for i:=1 to a do if l<r then l:=l+1 else r:=r+1;
 write(min(l,r)*2);
end.


var a,b:array[0..11,0..11]of longint;
    d1,d2:array[0..11]of longint;
    v:array[0..50,0..11]of longint;
    n,m,k,i,j,s:longint;
    num,ans:int64;
procedure check(max:longint);
   begin
      fillchar(d1,sizeof(d1),0);fillchar(d2,sizeof(d2),0);
      for i:=1 to n do for j:=1 to m do if a[i,j]<>0 then
         begin
            if(d1[a[i,j]]<>0)and(d1[a[i,j]]<>b[i,j])then exit;
            if(d2[b[i,j]]<>0)and(d2[b[i,j]]<>a[i,j])then exit;
            d1[a[i,j]]:=b[i,j];d2[b[i,j]]:=a[i,j];
         end;
      s:=0;for i:=1 to max do if d2[i]=0 then s:=s+1;
      num:=1;for i:=1 to s do num:=num*(k-max+s+1-i)mod 1000000007;ans:=(ans+num)mod 1000000007;
   end;
procedure dfs(p,x,y,max:longint);
   var i,j:longint;
   begin
      if x>n then begin check(max);exit;end;
      if y>m then begin dfs(p,x+1,1,max);exit;end;
      for i:=1 to x do for j:=1 to y do inc(v[p,b[i,j]]);
      for i:=1 to max do if v[p,i]=0 then begin b[x,y]:=i;dfs(p+1,x,y+1,max);end;
      if(max+1<=k)and(v[p,max+1]=0)then begin b[x,y]:=max+1;dfs(p+1,x,y+1,max+1);end;
      for i:=1 to x do for j:=1 to y do dec(v[p,b[i,j]]);
   end;
begin
   readln(n,m,k);if n+m-1>k then begin writeln(0);halt;end;
   for i:=1 to n do for j:=1 to m do read(a[i,j]);
   dfs(1,1,1,0);writeln(ans);
end.


var n, ans: int64;
    i: longint;
begin
    read(n);
    ans := (n div 210)*48;
    for i := 1 to (n mod 210) do if ((((i mod 2 <> 0) and (i mod 3 <> 0)) and (i mod 5 <> 0)) and (i mod 7 <> 0)) then inc(ans);
    write(ans);
end.


const file_in='';
      file_out='';
var f:text;
    a,b,c,gt:int64;
    i,j,count:longint;
    s,temp:string;
function convert(s:string):int64;
    var i,l:longint;
        k,temp:int64;
    begin
        k:=0;
        l:=length(s);
        temp:=1;
        for i:=l downto 1 do
            begin
                if s[i]='1' then k:=k+temp;
                temp:=temp*2;
            end;
        convert:=k;
    end;
begin
assign(f,file_in);  reset(f);
    read(f,a,b);
close(f);
count:=0;
temp:='1';
gt:=1;
while gt<=b do
    begin
        temp:=temp+'1';
        gt:=convert(temp);
        s:=temp;
        for i:=2 to length(s) do
            begin
                s[i]:='0';
                c:=convert(s);
                if (a<=c)and(c<=b) then inc(count);
                s[i]:='1';
            end;
    end;
assign(f,file_out); rewrite(f);
    writeln(f,count);
close(f);
end.


uses
  math;

var
  i, j, n, m, k, r, c, x, y, rr, l, d, u: longint;

begin
  readln (n, x, y, c);
  j := 1;
  rr := 1;
  l := x;
  r := x;
  u := y;
  d := y;
  k := 1;

  while k < c do
    begin
      if j = 1 then
        rr := 4 else rr := rr + 4;
      inc(j);
      l := l - 1;
      r := r + 1;
      u := u - 1;
      d := d + 1;
      k := k + rr;
      if l < 1 then
        k := k + (l - 1) * 2 + 1;
      if u < 1 then
        begin
          if (1 - l + 1 - u >= j) and (l < 1) then
            k := k - j + ((1 - l) * 2 - 1) - ((1 - u) - 1) - (-l)
          else
            k := k + (u - 1) * 2 + 1;
        end;
      if r > n then
        if u < 1 then
          k := k - min(j + (u - 1), r - n) - (r - n - 1)
        else
          k := k - ((r - n) * 2 - 1);
      if d > n then
        begin
          if r > n then
            k := k - min(j - r + n, d - n)
          else
            k := k - (d - n);
          if l < 1 then
            k := k - min(j + (l - 1) - 1, d - n - 1)
          else
            k := k - (d - n - 1);
        end;
    end;

  write (j-1);
end.


uses math;
const fi='';
      fo='';
var n,a,b,p,q,c,r,t1,t2:int64;
function gcd(x,y:int64):int64;
var t:int64;
begin
        while y<>0 do
                begin
                        t:=x mod y;
                        x:=y;
                        y:=t;
                end;
        exit(x);
end;
begin
        assign(input,fi); reset(input);
        assign(output,fo); rewrite(output);
        readln(n,a,b,p,q);
        c:=n div (a*b div gcd(a,b));
        r:=n div a*p+n div b*q;
        if p<q then r:=r-c*p
        else r:=r-q*c;
        write(r);
        close(input);
        close(output);
end.


  const eps=0.0000000001;  besk=20000000000008;  nn=200000;
   label 1,2,3,4;
    type    real=extended;  {string=ansistring;}
  {  mas=array [-10..nn] of int64; }  point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
   { mass1=^mass; }
    var qq,kk,cc,pp,rr,v1,v2,kol,t,p,sum,k1,ii,jj,q,pos,z,pmax,imax,p1,p2,p3,p4,l,ot,nm,n,s1,s2,m,s,smin,cen,dl,t2,i1:int64;
    k,h,step,i,j:longint;
    tt,modul,aaa,bbb, aa,bb,ccc,dd:int64;
    xnew,xold, bold,bnew,r,x,y,d,c,aold,b,a:array[-10..300000] of int64;
     dda:array[-10..1200,-10..1200] of int64;
     marked:array[-10..300030] of boolean;
   zanx,zany:array[-10..200000] of boolean;
    sss, ss1,ss2:string;
    sot:array [-10..1000000] of char;
     zan,fl:array[-10..200000] of boolean;
    ss:string;ch:char;
   mm,matr,ddp, pole :array [-10..100,-10..100,-10..101] of int64;
   sm:array[-10..100,-10..100,-10..100] of int64;
    maxpr:array[0..nn] of string;
    st2:array[0..nn] of string;
     left,right,v0,s0,t0:extended;
     zv:point;
     newx,newy,xx,yy:array[-1..200000] of int64;

     yot:double;
       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 degg(p,deg:int64):int64; var pp,q:int64;
 begin if deg=0 then degg:=1 else begin   if odd(deg) then degg:=degg(p,deg-1)*p mod modul else
 begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul;   end; end;   end;

 function fib(nn:int64):int64; var i,j,k,step:longint;  p,t,q:int64;
 begin
    matr[1,1,0]:=1;
    matr[2,1,0]:=1;
    matr[1,2,0]:=1;
    for i:=1 to 2 do for j:=1 to 2 do for step:=1 to 100 do matr[i,j,step]:=0;
   { writeln(modul);
    } for step:=1 to 60 do for i:=1 to 2 do for j:=1 to 2 do for k:=1 to 2 do
       matr[i,j,step]:=(matr[i,j,step]+matr[i,k,step-1]*matr[k,j,step-1]) mod modul;

     p:=nn;  q:=0;
     mm[1,1,0]:=1; mm[2,2,0]:=1;
      for i:=1 to 2 do for j:=1 to 2 do for step:=1 to 100 do mm[i,j,step]:=0;

     t:=0;
     while p>0 do begin  inc(t); a[t]:=p mod 2; p:=p div 2; end;
    { for i:=1 to t do write(a[i],' '); writeln;
   } for step:=1 to t do if a[step]>0 then
     begin
      inc(q);
      for i:=1 to 2 do for j:=1 to 2 do for k:=1 to 2 do
       mm[i,j,q]:=(mm[i,j,q]+matr[i,k,step-1]*mm[k,j,q-1]) mod modul;

     end;
   fib:=mm[1,1,q];

 end;

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

     read(n,kk,l,modul);  t:=0;
   while kk>0 do begin inc(qq); c[qq]:=kk mod 2; kk:=kk div 2;  end;
  { for i:=1 to l do writeln(i,' ',c[i],' '); writeln;
  } ot:=1;
   p:=fib(n+1);
   tt:=degg(2,n);
  { writeln(p,' ',tt,' ',tt-p);

  }
 {  for i:=1 to qq do writeln(i,' ',c[i]);
  }
   flag:=true;
   for i:=1 to 10000 do if (c[i]=1)and(i>l) then flag:=false;
   if not flag or (modul=1) then begin write(0); goto 1;   end;
   for step:=1 to l do
     begin
         if c[step]=0 then ot:=(ot*p) mod modul
         else ot:=(ot*(tt-p+modul)) mod modul;
         if (c[step]=1)and(step>qq) then ot:=0;
        { writeln(step,' == ',c[step]);
         if c[step]=1 then writeln(step,' ',p,'*') else writeln(step,' ',(tt-p+modul) mod modul,'*');
         }
     end;
     {writeln;
    } writeln(ot);

   1:          close(output);
end.


var n:int64;
begin
read(n);
write(n*n+(n-1)*(n-1));
end.


var
  k,x:longint;
begin
  read(k);
  case k mod 10 of
    0..5:x:=0;
    6..9:x:=1;
  end;
  write((k div 10+x)*10);
end.


const p=998244353;
var i,k,j,n,m:longint;a,b:array[0..2001]of int64;
begin
 read(n,m,k);
 a[0]:=m;
 for j:=1 to n-1 do
 begin
 b:=a;
 for i:=1 to K do
 a[i]:=(B[I]+B[I-1]*(M-1)) MOD P;
 end;
 WRITE(A[K])
end.


var
  k1, k2, u1, u2, a, t1, b, t2, l, k: real;

begin
  read(a, b, t1, t2);
  k1 := (3 * a) / 10;
  k2 := (3 * b) / 10;
  u1 := a - (a / 250) * t1;
  u2 := b - (b / 250) * t2;
  if k1 > u1 then
  begin
    k := k1;
  end
  else
  begin
    k := u1;
  end;
  if k2 > u2 then
  begin
    l := k2;
  end
  else
  begin
    l := u2;
  end;
  if k > l then writeln('Misha');
  if k < l then writeln('Vasya');
  if k = l then writeln('Tie');
end.


const
        fi='';
var
        f:text;
        n,a,b,c,kq:longint;
procedure nhap;
begin
        assign(f,fi);
        reset(f);
        readln(f,n,a,b,c);
        close(f);
end;
procedure xuly;
var
        i,j,u,v:longint;
begin
        for i:=0 to b do
        for j:=0 to c do
        begin
                u:=n-(i+2*j);
                if u>=0 then
                begin
                        u:=u*2;
                        if a>=u then inc(kq);
                end;
        end;
        writeln(kq);
end;
begin
        nhap;
        xuly;
end.


uses math;
const inf=1e30;
	eps=1e-8;
type	ext=	extended;
	vc=	object
			x,y:ext;
			function length:ext;
			function sqrlen:ext;
			function zoom(const l:ext):vc;
			function vtl:vc;
		end;

	function fsqrt(const x:ext):ext; begin if abs(x)<eps then exit(0) else exit(sqrt(x)); end;
	function plus(const a,b:vc):vc; begin plus.x:=a.x+b.x; plus.y:=a.y+b.y; end;
	function minus(const a,b:vc):vc; begin minus.x:=a.x-b.x; minus.y:=a.y-b.y; end;
	function star(const a:vc; const b:ext):vc; begin star.x:=a.x*b; star.y:=a.y*b; end;
	function divi(const a:vc; const b:ext):vc; begin divi.x:=a.x/b; divi.y:=a.y/b; end;
	function cross(const a,b:vc):ext; begin cross:=a.x*b.y-a.y*b.x; end;
	function dot(const a,b:vc):ext; begin dot:=a.x*b.x+a.y*b.y; end;
	function vc.length:ext; begin exit(fsqrt(x*x+y*y)); end;
	function vc.sqrlen:ext; begin exit(x*x+y*y); end;
	function vc.zoom(const l:ext):vc; begin exit(star(self,(l/self.length))); end;
	function vc.vtl:vc; begin vtl.x:=-y; vtl.y:=x; end;

var
p,s1,s2:array[0..100010] of vc;
RR:extended;

function cmp(const a,b:vc):boolean;
begin if abs(a.x-b.x)<eps then exit(a.y+eps<b.y) else exit(a.x<b.x); end;

procedure sort(l,r:longint);
var i,j:longint;
    x,y:vc;
begin i:=l;
	j:=r;
	x:=p[(l+r)>>1];
	repeat
		while cmp(x,p[i]) do inc(i);
		while cmp(p[j],x) do dec(j);
		if not(i>j) then
		begin y:=p[i];
			p[i]:=p[j];
			p[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 graham(var n:longint);
var top1,top2,i:longint;
begin sort(1,n);
	top1:=0; top2:=0;
	for i:=1 to n do
	begin while (top1>=2)and(cross(minus(s1[top1],s1[top1-1]),minus(p[i],s1[top1-1]))<eps) do dec(top1);
		inc(top1); s1[top1]:=p[i];
	end;
	for i:=n downto 1 do
	begin while (top2>=2)and(cross(minus(s2[top2],s2[top2-1]),minus(p[i],s2[top2-1]))<eps) do dec(top2);
		inc(top2); s2[top2]:=p[i];
	end;
	n:=0;
	for i:=1 to top1 do begin inc(n); p[n]:=s1[i]; end;
	for i:=2 to top2-1 do begin inc(n); p[n]:=s2[i]; end;
end;

function out(const a,b,c:vc):boolean;
begin exit(minus(c,(plus(star(plus(a,b),0.5),minus(b,a).vtl.zoom(fsqrt(RR*RR-minus(b,a).sqrlen/4))))).sqrlen>RR*RR+eps); end;

procedure lemon;
var n,i,all,l,r:longint;
    theta,ans:extended;
begin readln(n,RR);
	for i:=1 to n do readln(p[i].x,p[i].y);
	if n<=1 then begin writeln('0.0000000000'); exit; end;
	graham(n);

	all:=0;
	for i:=1 to n do
	begin while (all>1)and(dot(minus(s1[all],s1[all-1]),minus(p[i],star(plus(s1[all],s1[all-1]),0.5)))>eps)and(out(s1[all-1],s1[all],p[i])) do dec(all);
		inc(all); s1[all]:=p[i];
	end;
	l:=1; r:=all;
	while l+1<r do
		if out(s1[l],s1[l+1],s1[r]) then
			inc(l)
		else  if out(s1[r-1],s1[r],s1[l]) then
				dec(r)
			else break;
	all:=0;
	for i:=l to r do begin inc(all); p[all]:=s1[i]; end;

	p[all+1]:=p[1]; ans:=0;
	for i:=1 to all do
	begin theta:=arcsin(minus(p[i+1],p[i]).length/(2*RR))*2;
		ans:=ans+cross(p[i],p[i+1])+RR*RR*(theta-sin(theta));
	end;
	writeln(abs(ans)/2+eps:0:10);
end;

begin
{$ifndef ONLINE_JUDGE}
	assign(input,'154E.in');
	reset(input);
{$endif}
lemon;
end.


Var a: array [0..1000] of longint;
    n,k,j,i,f:longint;
Begin
     readln(n,k);f:=0;
     for i:=1 to n do
     read(a[i]);
     for i:=1 to n do
     if a[i] <= k then f:=f+1
      else break;
     for j:=n downto 1 do
     if (a[i] <> a[j]) and (a[j] <= k) then f:=f+1
      else break;
     writeln(f);
end.


program zz;

var a,b,s,m,j,i,c,k,n,z:int64;
begin
 {assign(input,'input.txt');reset(input);
 assign(output,'output.txt');rewrite(output);}
  read(m,n,s);
  if m mod s=0 then a:=m else a:=(m div s+1)*(m mod s);
  if n mod s=0 then b:=n else b:=(n div s+1)*(n mod s);
  write(a*b);

{ close(input);
  close(output);                                    }
end.


var
        k,g:int64;
        i,j,n:longint;
        a:array [0..100000] of int64;
begin
readln(n,k);
for i:=1 to n do
        a[i]:=a[i-1]*2+1;
for i:=n downto 1 do
        if a[i]<k then
                begin
                k:=k-a[i];
                if k=1 then
                        begin
                        writeln(i+1);
                        halt;
                        end
                else
                        dec(k);
                end
        else
        if a[i]=k then
                begin
                writeln(1);
                halt;
                end;
end.


var s,p:string;
    c:char;
    i,n,j:longint;

begin

  readln(s); read(p);
  for i:=1 to length(s)-1 do
    begin
      c:=s[i];
      n:=i;
      for j:=i+1 to length(s) do
        if ord(s[j])<ord(c) then
          begin
            c:=s[j];
            n:=j;
          end;
      s[n]:=s[i];
      s[i]:=c;
    end;

  i:=1;
  while s[i]='0' do inc(i);
  if i<=length(s) then
    begin
      c:=s[i];
      s[i]:=s[1];
      s[1]:=c;
    end;

  if s=p then write('OK')
  else write('WRONG_ANSWER');

end.


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

var n, k: integer;

procedure readdata;
begin
    read(n, k);
end;

procedure init;
begin
end;

function calculate(v, k: integer): boolean;
var s: int64; den: int64;
begin
    s := 0; den := 1;
    while (v div den > 0) and (s < n) do begin
        s := s + v div den;
        den := den * k;
    end;
    result := s >= n;
end;

function bsearch(l, r: integer): integer;
begin
    while l < r - 2 do
        if calculate((l + r) div 2, k) then
            r := (l + r) div 2 + 1
        else
            l := (l + r) div 2 + 1;
    if calculate(l, k) then
        result := l
    else
        result := r - 1
end;

function solve: integer;
begin
    result := bsearch(0, n+1)
end;

procedure save(value: integer);
begin
    writeln(value);
end;

begin
    init;
    readdata;
    save(solve);
    readln;readln;
end.


var s,n,m:integer;
begin
read(n,m);
s:=1;
while (s<=m) and (n>0) do begin dec(n); s:=s*2; end;
write(m mod s);
end.


program cf560B;
uses math;
var a1s,b1s,a2s,b2s,a3s,b3s:integer;
begin
read(a1s,b1s,a2s,b2s,a3s,b3s);

if ((a2s+a3s<=a1s) and (max(b2s,b3s)<=b1s)) or ((a2s+a3s<=b1s) and (max(b2s,b3s)<=a1s))
or ((a2s+b3s<=a1s) and (max(b2s,a3s)<=b1s))
or ((a2s+b3s<=b1s) and (max(b2s,a3s)<=a1s))

or ((b2s+b3s<=b1s) and (max(a2s,a3s)<=a1s)) or ((b2s+b3s<=a1s) and (max(a2s,a3s)<=b1s))
or ((b2s+a3s<=b1s) and (max(a2s,b3s)<=a1s))
or ((b2s+a3s<=a1s) and (max(a2s,b3s)<=b1s))

then writeln('YES')
else writeln('NO');
end.


var
	x, y, z: integer;
	n, m: integer;

begin
	{$string_nullbased+}

	readln(x, y, z);
	n := x + z;
	m := y + z;
	if ((n > y) and (m < x)) then writeln('+')
	else if ((m > x) and (n < y)) then writeln('-')
	else if ((n = y) and (m = x)) then writeln(0)
	else writeln('?');

end.


{$apptype console}
{$r+,q+,s+,i+,o+}
{$ifdef fpc}
{$mode delphi}
{$endif}
{ $minstacksize 5000000}
{ $define files}
uses SysUtils;
var n:integer;
    s:string;
    i,j,k:integer;
    ok:boolean;

begin
DecimalSeparator:='.';
{$ifdef files}
assign(input,'a.in');reset(input);
assign(output,'a.out');rewrite(output);
{$endif}
readln(n);
readln(s);
for i:=1 to n do begin
    if s[i]='.' then continue;
    for j:=1 to n do begin
        if i+4*j>n then continue;
        ok:=true;
        for k:=1 to 4 do
            if s[i+k*j]='.' then ok:=false;
        if ok then begin
           writeln('yes');
           halt;
        end;
    end;
end;
writeln('no');
end.


var c:char;
n,i,j,res:longint;
ans:array [0..10] of string;
s:string;
begin
ans[1]:='vaporeon';
ans[2]:='jolteon';
ans[3]:='flareon';
ans[4]:='espeon';
ans[5]:='umbreon';
ans[6]:='leafeon';
ans[7]:='glaceon';
ans[8]:='sylveon';

readln(n);
for i:=1 to n do begin
  read(c);
  s:=s+c;
end;
for i:=1 to 8 do begin
//  writeln(length(ans[i]));
  if length(ans[i])=n then begin
    j:=1;
    while ((ans[i][j]=s[j]) or (s[j]='.')) and (j<n) do begin
//      write(ans[i][j],' ');
      j:=j+1;
    end;
//    writeln();
    if (ans[i][j]=s[j]) or (s[j]='.') then begin
      res:=i;
      break;
    end;
  end;
end;

writeln(ans[res]);
end.


var n,k:integer;
n1,k1:int64;
a,b:double;
c,s:string;
i:integer;
begin
read(s);
c:='';
c:=c+s[1]+s[3]+s[5]+s[4]+s[2];
val(c,n,k);
k1:=n;
n1:=n;

for i:=1 to 4 do
n1:=n1*k1 mod 100000 ;
n:=n1;
str(n,s);

for i:=1 to 5-length(s) do
write('0');
write(n);
end.


   Uses     Math;
   Const    Nmax    =   Round(5e3) + 3;
            Base    =   Round(1e9) + 7;
   Var      f      :       array  [0..Nmax, 0..Nmax]  Of  Int64;
            n, k, a, b    :   Longint;
            d   : array  [0..Nmax]  Of  Int64;
   {--------------------------------------}
   Procedure Openf;
     Begin
  //      Assign(input,'lift.inp');  Reset(input);
  //      Assign(output,'lift.out');  Rewrite(output);
        Readln(n, a, b, k);
     End;
   {---------------------------------------}
   Procedure Process;
   Var  i, j, t, l, r, res  :  Longint;
     Begin
         F[a, 0]  := 1;
         For  j  := 1 to K do
           Begin
               Fillchar(d, sizeof(d), 0);
               For  t  := 1 to N do
                  Begin
                    If t = b then Continue;
                    l   := Max(1, t - abs(t - b) + 1);
                    r   := Min(n, t + abs(t - b) - 1);
                    D[l]  := (D[l] + F[t, j - 1]) Mod Base;
                    D[r + 1]  := (D[r + 1] - F[t, j - 1] + Base) Mod base;
                  End;
               For  i := 1 to N do D[i]  := (d[i - 1] + D[i]) Mod Base;
               For  i := 1 to N do F[i, j]  := (D[i] - F[i, j - 1] + Base) Mod base;
           End;

         Res  := 0;
         For  i  := 1 to N do
          If i <> b then
           Res  := (Res + F[i, k]) Mod Base;

         Writeln(Res);
     End;
   {-----------------------------------------------------------------------------------------}
   BEGIN
     Openf;
     Process;
   END.


uses math;
var
  i,j,a,b,c,res,temp:longint;

begin
  read(a,b,c);
  res:=res+a div 3;
  res:=res+b div 3;
  res:=res+c div 3;
  temp:=res;
  a:=a-1;
  b:=b-1;
  c:=c-1;
  if (a>=0) and (b>=0) and (c>=0) then
  begin
  res:=0;
  res:=res+a div 3;
  res:=res+b div 3;
  res:=res+c div 3;
  temp:=max(temp,res+1);
  end;
  a:=a-1;
  b:=b-1;
  c:=c-1;
  if (a>=0) and (b>=0) and (c>=0) then
  begin
  res:=0;
  res:=res+a div 3;
  res:=res+b div 3;
  res:=res+c div 3;
  temp:=max(temp,res+2);
  end;
  writeln(temp);
end.


{$R+}{$Q+}
Uses math;
Const md=1000000009;
Var a,rez,n,w,b:int64;
i:longint;
fac:array [0..10000] of int64;
function pow(k,z:int64):int64;
Var x:int64;
begin
  if z=0
  then pow:=1
  else begin
        x:=pow(k,z div 2);
        x:=(x*x) mod md;
        if z mod 2=1
        then x:=(x*k) mod md;
        pow:=x;
       end;
end;
function c(k,n:int64):int64;
begin
  if k>n
  then c:=0
  else c:=(fac[n]*pow((fac[k]*fac[n-k])mod md,md-2)) mod md;
end;
function ff(a,b:longint):int64;
begin
  ff:=(fac[b+a-1]*pow(fac[b-1], md-2)) mod md;
end;
begin
//  Assign(input,'input.txt'); reset(input);
//  Assign(output,'output.txt'); rewrite(output);
  readln(n,w,b);
  fac[0]:=1;
  for i:=1 to 10000 do
  fac[i]:=(fac[i-1]*i) mod md;
  rez:=0;
  for i:=2 to n do
  if (n-i>=1)and(i<=w)and(n-i<=b)
  then begin
        a:=i-1;
        a:=(a*fac[i]) mod md;
        a:=(a*fac[n-i]) mod md;
        a:=(a*c(i,w)) mod md;
        a:=(a*c(n-i,b)) mod md;
        a:=(a*ff(w-i,i)) mod md;
        a:=(a*ff(b-n+i,n-i)) mod md;
        rez:=(rez+a) mod md;
//        rez:=(rez+(i-1)*(fac[i]*fac[n-i] mod md)*(c(i,w)*c(n-i,b) mod md)*(ff(w-i,i)*ff(b-n+i,n-i) mod md)) mod md;
       end;
  writeln(rez);
end.


var n:int64;
    begin
    readln(n);
    n:=sqr(n-2);
    write(n);
    end.


{$o-}
var
   ch  :  char;
   n,m,i : longint;
    hour,minut   :   string;
    h,min  : extended;
begin
   {assign(input,'a.in');  }    reset(input);
   {assign(output,'a.out'); }   rewrite(output);
    n:=0;
    m:=0;
       for i:=1 to 5 do begin
         read(ch);
        if (i=1) or (i=2) then
           n:=n*10+(ord(ch)-48) else
        if (i=4) or (i=5) then
           m:=m*10+(ord(ch)-48);
        end;
        if (n>=12) then n:=n - 12;
       h:=(n*30)+(m/60)*30;
       min:=(m / 5)*30;
        write(h:0:6,' ',min:0:6);
            close(input);
            close(output);
end.


Var n,i,rez,a,b:longint;
m:array [1..1000000] of LongInt;
begin
//  Assign(input,'input.txt'); reset(input);
//  Assign(output,'output.txt'); rewrite(output);
  readln(n);
  rez:=0; a:=0;b:=0;
  for i:=1 to n do
  begin
    m[i]:=1;
    if Odd(i)
    then begin
          m[i]:=(m[i]+b) mod 1000000007;
          a:=(a+m[i])mod 1000000007;
         end
    else begin
          m[i]:=(m[i]+a)mod 1000000007;
          b:=(b+m[i])mod 1000000007;
         end;
    rez:=(rez+m[i]) mod 1000000007;
  end;
  Writeln(rez);
end.


type mas=record
         p,x:longint;
         end;
function max(a,b:longint):longint;
begin
if a>b then max:=a else max:=b;
end;

var n,c,i,sum1,sum2,x:longint;
A:array [1..100] of mas;
begin
readln(n,c);
for i:=1 to n do
read(A[i].p);

for i:=1 to n do
read(A[i].x);

x:=0;
sum1:=0;
for i:=1 to n do
begin
x:=x+A[i].x;
sum1:=sum1+max(0,A[i].p-c*x);
end;

x:=0;
sum2:=0;
for i:=n downto 1 do
begin
x:=x+A[i].x;
sum2:=sum2+max(0,A[i].p-c*x);
end;

if sum1>sum2 then writeln('Limak') else
  if sum2>sum1 then writeln('Radewoosh') else
     writeln('Tie');

end.


const mod1=1000000007;
var
k,q,x,r,i,n:int64;
function phi (n:int64):int64;
begin
    r:=n;
    i:=2;
    while sqr(i)<=n do begin
        if n mod i = 0 then begin
            while n mod i = 0 do n:=n div i;
            r:=r-r div i;
        end;
            inc(i);
    end;
        if n>1 then r:=r-r div n;
        phi:=r;
end;
begin
readln(x,k);
phi(x);
q:=k div 2;
if k mod 2= 1 then inc(q);
k:=1;
while true do begin
     x:=phi(x);
     if x=1 then break;
     inc(k);
     if k>q then break;
end;
writeln(x mod mod1 );
end.


{$APPTYPE CONSOLE}
{R+,S+,Q+,I+,C+,M+,H+,O+}
{$R-,S-,Q-,I-,C+,M-,H+,O-}

uses
    SysUtils, Math;

var
    i, ls, lh, lm, mnh, mnm, hmn, mmn : longint;
    s, mm, hh : string;
    ch, cm : char;

function max(a, b : char) : char; overload;
begin
    if a > b then result := a else result := b;
end;

const
    DIGITS : array[1..36] of char = ('0', '1', '2', '3', '4', '5', '6', '7', '8',
                                                                     '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
                                                                     'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
                                                                     'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');

function PToDec(p : longint; n : string) : int64;

var
    current, step, index : int64;
    i, j : longint;

begin
    step := 1;
    current := 0;
    for i := length(n) downto 1 do begin
        index := 1;
        for j := 1 to 36 do
            if digits[j] = n[i] then index := j;
        current := current + step * (index - 1);
        step := step * p;
    end;
    ptodec := current;
end;

procedure put(x : longint);
begin
    write(x);
    halt(0);
end;

begin
    readln(s);
    ls := length(s);
    hh := '';
    mm := '';
    i := 1;
    while s[i] <> ':' do begin
        if (hh = '') and (s[i] = '0') then else hh := hh + s[i];
        inc(i);
    end;
    inc(i);
    while i <= ls do begin
        if (mm = '') and (s[i] = '0') then else mm := mm + s[i];
        inc(i);
    end;
    if hh = '' then hh := '0';
    if mm = '' then mm := '0';
    lh := length(hh);
    lm := length(mm);
    ch := #0;
    for i := 1 to lh do
        ch := max(ch, hh[i]);
    cm := #0;
    for i := 1 to lm do
        cm := max(cm, mm[i]);
    mnh := 0;
    for i := 1 to 36 do
        if digits[i] = ch then begin
            mnh := i;
            break;
        end;
    mnh := max(mnh, 2);
    mnm := 0;
    for i := 1 to 36 do
        if digits[i] = cm then begin
            mnm := i;
            break;
        end;
    mnm := max(mnm, 2);
    hmn := ptodec(mnh, hh);
    mmn := ptodec(mnm, mm);
    if (hmn > 23) or (mmn > 59) then put(0);
    if (lh = 1) and (lm = 1) then put(-1);
    i := max(mnh, mnm);
    while true do begin
        hmn := ptodec(i, hh);
        mmn := ptodec(i, mm);
        if (hmn < 24) and (mmn < 60) then write(i, ' ') else break;
        inc(i);
    end;
end.


program LH;
var
   i,n,t:longint;
begin
   readln(n);n:=n*2;
   for i:=1 to trunc(sqrt(n)) do
    begin
       t:=n-i*(i+1);
       if (t<=0) then break;
       if (t=trunc(sqrt(t))*(trunc(sqrt(t))+1)) then
        begin
           writeln('YES');
           halt;
        end;
    end;
   writeln('NO');
end.


var i,j,n,x,y,amin,amax,g:longint;
    min,max,s,w:array[0..7,0..7] of longint;
    v:array[0..7] of longint;
procedure tt(x,y:longint);
var i,j,f,g:longint;
    q:boolean;
 begin
  for i:=1 to x-1 do
   begin
    f:=0;
    for j:=i+1 to n do
     f:=f+w[i,j];
    if f>v[i] then exit;
   end;
  if x=n then begin
               if v[1]=v[n] then begin
                                  q:=true;
                                  for i:=1 to n-1 do
                                   begin
                                    f:=0;
                                    for j:=i+1 to n do
                                     begin
                                      if (w[i,j]<min[i,j]) or
                                         (w[i,j]>max[i,j]) then begin
                                                                 q:=false;
                                                                 exit;
                                                                end;

                                      f:=f+w[i,j];
                                     end;
                                    if f<>v[i] then begin
                                                     q:=false;
                                                     exit;
                                                    end;
                                   end;
                                  if q then begin
                                             f:=0;
                                             for i:=1 to n-1 do
                                              for j:=i+1 to n do
                                               if w[i,j]>0 then f:=f+s[i,j]+sqr(w[i,j]);
                                             if (v[1]<amin) or
                                               ((v[1]=amin) and
                                                 (f>amax)) then begin
                                                                 amin:=v[1];
                                                                 amax:=f;
                                                                end;
                                            end;
                                 end;
               exit;
              end;
  for i:=min[x,y] to max[x,y] do
   begin
    v[y]:=v[y]+i;
    w[x,y]:=i;
    if y+1>n then tt(x+1,x+2)
             else tt(x,y+1);
    v[y]:=v[y]-i;
    w[x,y]:=0;
   end;
 end;

 begin
  read(n);
  g:=0;
  for i:=1 to n-1 do
   for j:=i+1 to n do
    begin
     read(x,y);
     read(min[x,y],max[x,y],s[x,y]);
     g:=g+min[x,y];
    end;
  amin:=100;
  amax:=0;
  for i:=0 to 80 do
   begin
    fillchar(v,sizeof(v),0);
    fillchar(w,sizeof(w),0);
    v[1]:=i;
    tt(1,2);
    if amin<100 then break;
   end;
  if amin=100 then writeln('-1 -1')
              else writeln(amin,' ',amax);
 end.


var i,j,a,b1,b,anss:longint;
    ans:array[1..100] of longint;
begin
  readln(a,b1);
  b:=b1;
  anss:=0;
  fillchar(ans,sizeof(ans),0);
  while (b>a) do
  begin
    if (b mod 10=1) then
    begin
	  b:=b div 10;
	  inc(anss);
	  ans[anss]:=b;
	end
	else if (b mod 2=0) then
	begin
	  b:=b div 2;
	  inc(anss);
	  ans[anss]:=b;
	end
	else
	begin
	  writeln('NO');
	  halt;
	end;
  end;
  if (b=a) then
  begin
    writeln('YES');
    writeln(anss+1);
    for i:=anss downto 1 do
		write(ans[i],' ');
	writeln(b1);
  end else writeln('NO');
end.


const
  c: array['0'..'9'] of longint = (6, 2, 5, 5, 4, 5, 6, 3, 7, 6);
var
  i, a, b, sum: longint;
  s, n: ansistring;

begin
  readln(a, b);
  for i:= a to b do
        begin
          str(i, n);
          s:= s + n;
        end;
  for i:= 1 to length(s) do
        inc(sum, c[s[i]]);
  writeln(sum);
end.


{$R-,S-,Q-,I-,O+}
var
  typ,aux: array [0..1111] of longint;
  b,dd,d,x,i: longint;

function gcd(a,b:longint):longint;
begin
  while (a > 0) and (b > 0) do
    if a > b then a:=a mod b
    else b:=b mod a;
  gcd:=a+b;
end;

begin
  read(b,dd);
  for d:=2 to dd do
  begin
    typ[d]:=0;
    x:=1;
    for i:=1 to 1000 do
    begin
      x:=x*b mod d;
      if x = 0 then
      begin
        typ[d]:=2;
        aux[d]:=i;
        break;
      end;
    end;
    if typ[d] = 0 then
      if b mod d = 1 then typ[d]:=3 else
      if b mod d = d-1 then typ[d]:=11 else
      begin
        for i:=2 to d-1 do
          if d mod i = 0 then
            if gcd(i,d div i) = 1 then
              if (typ[i] <> 7) and (typ[d div i] <> 7) then
              begin
                typ[d]:=6;
                break;
              end;
        if typ[d] = 0 then typ[d]:=7;
      end;
  end;
  writeln(typ[dd],'-type');
  if typ[dd] = 2 then writeln(aux[dd]);
end.


var s,s1:string;
i,j,a,a1,b,b1,c,d,n,m:longint;
begin
readln(n,m);
s:=s+'1';
s1:=s1+'1';
if (n=1) and (m=0) then writeln(0,' ',0)
 else
 if (((n*9)<m) or (m=0)) then writeln(-1,' ',-1) else
 begin
for i:=2 to n do
begin
s:=s+'0';
s1:=s1+'0';
end;
a:=1;
a1:=1;
b:=length(s);
b1:=1;
while true do
begin
if a=m then break;
case s[b] of
'0':begin s[b]:='1'; inc(a) end;
'1':begin s[b]:='2'; inc(a) end;
'2':begin s[b]:='3'; inc(a) end;
'3':begin s[b]:='4'; inc(a) end;
'4':begin s[b]:='5'; inc(a) end;
'5':begin s[b]:='6'; inc(a) end;
'6':begin s[b]:='7'; inc(a) end;
'7':begin s[b]:='8'; inc(a) end;
'8':begin s[b]:='9'; inc(a) end;
'9':begin dec(b); end;
end;
end;
while true do
begin
if a1=m then break;
case s1[b1] of
'0':begin s1[b1]:='1'; inc(a1) end;
'1':begin s1[b1]:='2'; inc(a1) end;
'2':begin s1[b1]:='3'; inc(a1) end;
'3':begin s1[b1]:='4'; inc(a1) end;
'4':begin s1[b1]:='5'; inc(a1) end;
'5':begin s1[b1]:='6'; inc(a1) end;
'6':begin s1[b1]:='7'; inc(a1) end;
'7':begin s1[b1]:='8'; inc(a1) end;
'8':begin s1[b1]:='9'; inc(a1) end;
'9':begin inc(b1); end;
end;
end;
writeln(s,' ',s1);

 end;
end.


var h,t1,t2,s,x,p,z:int64;
begin
readln(s,x);
if (s-x) and 1=1 then begin write('0'); exit;end
 else p:=(s-x) div 2;
if s<x then begin write('0'); exit; end;
h:=p;
z:=1;
while (x<>0) or (p<>0) do
begin
t1:=x mod 2;
t2:=p mod 2;
// writeln(t1,' ',t2);
if (t1=1) then
begin
if t2=1 then begin write('0'); exit; end else z:=2*z;
end;
x:=x div 2;
p:=p div 2;
end;
if h=0 then z:=z-2;
write(z);
end.


Var n , k , s , p : Int64;
    Ans : Int64;

Function Max(tam1 , tam2 : Int64) : Int64;
    Begin If tam1 > tam2 then Exit(tam1) else Exit(tam2); End;
{Procedure Sort(l , r : Longint);
    Var i , j , x , y : Longint;
    Begin
    i := l; j := r;
    x := A[(l+r) div 2];
    Repeat
    While A[i] < x do Inc(i);
    While x < A[j] do Dec(j);
    If not (i > j) then
        Begin
        y := A[i]; A[i] := A[j]; A[j] := y;
        Inc(i); Dec(j);
        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 , x , y : Longint;
    Begin
    i := l; j := r;
    x := B[(l+r) div 2];
    Repeat
    While B[i] < x do Inc(i);
    While x < B[j] do Dec(j);
    If not (i > j) then
        Begin
        y := B[i]; B[i] := B[j]; B[j] := y;
        Inc(i); Dec(j);
        End;
    Until i > j;
    If l < j then sort1(l , j);
    If i < r then sort1(i , r);
    End; }

Begin
    Readln(k , n , s , p);
    Ans := n;
    If (Ans mod s = 0) then Ans := Ans div s else Ans := Ans div s + 1; Ans := Ans * k;
    If (Ans mod p = 0) then Ans := Ans div p else Ans := Ans div p + 1;
    Writeln(Ans);
End.


const
     inf=10000000000;
var
     a:array [0..2222,0..2222] of Extended;
     N,T,i,j:Longint;
     ans,p:Extended;
begin
     Readln(N,P,T);
     a[0,0]:=1;
     for i:=0 to T do
     for j:=0 to N do
     if j=N then a[i+1,j]:=a[i+1,j]+a[i,j]
            else begin
                      a[i+1,j+1]:=a[i+1,j+1]+a[i,j]*P;
                      a[i+1,j]:=a[i+1,j]+a[i,j]*(1-p);
                  end;
     ans:=0;
     for i:=0 to N do
     ans:=ans+a[t,i]*i;
     Writeln(ans:0:6);
 end.


var
  a, b, c, d, i, j: int64;
  ar: array [1..3, 1..3] of char;
  q, q1: boolean;

begin
  b := 0;
  c := 0;
  i := 1;
  while i <= 3 do begin
    j := 1;
    while j <= 3 do begin
      read(ar[i, j]);
      if ar[i, j] = 'X' then inc(b);
      if ar[i, j] = '0' then inc(c);
      inc(j);
    end;
    readln;
    inc(i);
  end;
  if c > b then begin
    writeln('illegal');
    halt();
  end;
  if c + 1 < b then begin
    writeln('illegal');
    halt();
  end;
  q := false;
  q1 := false;
  i := 1;
  while i <= 3 do begin
    if (ar[i, 1] = 'X') and (ar[i, 2] = ar[i, 1]) and (ar[i, 2] = ar[i, 3]) then q := true;
    if (ar[1, i] = 'X') and (ar[1, i] = ar[2, i]) and (ar[1, i] = ar[3, i]) then q := true;
    if (ar[i, 1] = '0') and (ar[i, 2] = ar[i, 1]) and (ar[i, 2] = ar[i, 3]) then q1 := true;
    if (ar[1, i] = '0') and (ar[1, i] = ar[2, i]) and (ar[1, i] = ar[3, i]) then q1 := true;
    inc(i);
  end;
  if (ar[1, 1] = 'X') and (ar[1, 1] = ar[2, 2]) and (ar[2, 2] = ar[3, 3]) then q := true;
  if (ar[3, 1] = 'X') and (ar[2, 2] = ar[3, 1]) and (ar[2, 2] = ar[1, 3]) then q := true;
  if (ar[1, 1] = '0') and (ar[1, 1] = ar[2, 2]) and (ar[2, 2] = ar[3, 3]) then q1 := true;
  if (ar[3, 1] = '0') and (ar[2, 2] = ar[3, 1]) and (ar[2, 2] = ar[1, 3]) then q1 := true;
  if (not(q)) and (not(q1)) and (b + c = 9) then begin
    writeln('draw');
    halt();
  end;
  if (not(q)) and (not(q1)) then begin
    if b = c then writeln('first')
    else writeln('second');
    halt();
  end;
  if (q) and (b = c) then begin
    writeln('illegal');
    halt();
  end;
  if (q) and (q1) then begin
    writeln('illegal');
    halt();
  end;
  if (q1) and (b > c) then begin
    writeln('illegal');
    halt();
  end;
  if q then writeln('the first player won')
  else writeln('the second player won');
end.


var a,s,d,f,g,h,j,k,l,i,ii:longint;
z:array[1..100000]of longint;
begin
readln(a);
for i:=1 to a do
read(z[i]);
for i:=1 to a do
s:=s+z[i];
if s=0 then
begin
     l:=1;
     while (s=0)and(l<=a) do
     begin
          s:=s+z[l];
          inc(l);
     end;
     if l<=a then
     begin
          writeln('YES');
          writeln(2);
          writeln(1,' ',l-1);
          writeln(l,' ',a);
     end
     else writeln('NO');
end
else
begin
    writeln('YES');
    writeln(1);
    writeln(1,' ',a);
end;
end.


const
	module=998244353;
var
	cb:array[0..5005,0..5005] of int64;
	p:array[0..5005] of int64;
	a,b,c,ans,ans1,ans2,ans3:int64;

procedure init;
var
	i,j:longint;
begin
	fillchar(cb,sizeof(cb),0);
	cb[0,0]:=1;
	for i:=1 to 5000 do
		begin
			cb[i,0]:=1;
			for j:=1 to i do
				cb[i,j]:=(cb[i-1,j]+cb[i-1,j-1]) mod module;
		end;
	p[1]:=1;
	for i:=2 to 5000 do p[i]:=p[i-1]*i mod module;
end;

procedure solve1;
var
	i:longint;
	tmp:int64;
begin
	ans1:=1;
	for i:=1 to a do
		begin
			tmp:=cb[a,i]*cb[b,i] mod module*p[i] mod module;
			ans1:=(ans1+tmp) mod module;
		end;
end;

procedure solve2;
var
	i:longint;
	tmp:int64;
begin
	ans2:=1;
	for i:=1 to a do
		begin
			tmp:=cb[a,i]*cb[c,i] mod module*p[i] mod module;
			ans2:=(ans2+tmp) mod module;
		end;
end;

procedure solve3;
var
	i:longint;
	tmp:int64;
begin
	ans3:=1;
	for i:=1 to b do
		begin
			tmp:=cb[b,i]*cb[c,i] mod module*p[i] mod module;
			ans3:=(ans3+tmp) mod module;
		end;
end;

begin
	init;
	readln(a,b,c);
	solve1;
	solve2;
	solve3;
	ans:=ans1*ans2 mod module*ans3 mod module;
	write(ans);
end.


var a:array[1..100] of longint;
    i,n,d,min,j,k:longint;

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

begin

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

readln(n,d);
for i:=1 to n do read(a[i]);
qsort(1,n);

min:=maxLongint;
for i:=1 to n do
begin
j:=n;k:=i-1;
while (a[j]-a[i]>d) do begin inc(k);dec(j);end;
if k<min then min:=k;
end;

writeln(min);

end.


var n,i,j,max,ans,now:longint;
    flag:boolean;
    ch:array[0..500] of char;
function flagg(x:char):boolean;
begin
  if (65<=ord(x)) and (ord(x)<=65+25) then exit(true);
  if (97<=ord(x)) and (ord(x)<=97+25) then exit(true);
  exit(false);
end;
begin
  readln(n);
  for i:=1 to n do
	read(ch[i]);
  readln;
  max:=0;
  ans:=0;
  flag:=true;
  i:=1;
  now:=0;
  while (i<=n) do
  begin
    if flagg(ch[i]) then inc(now);
	if not(flagg(ch[i])) then
	begin
	  if flag then
	  begin
	    if (now>max) then max:=now;
	    now:=0;
	  end
	  else
	  begin
	    if (now>0) then inc(ans);
		now:=0;
	  end;
	end;
	if (ch[i]='(') then flag:=false;
	if (ch[i]=')') then flag:=true;
	inc(i);
  end;
	if (now>0) then
	begin
	  if not(flag) then inc(ans);
	  if flag and(now>max) then max:=now;
	end;
	writeln(max,' ',ans);
end.


{$mode objfpc}

const           InputFile               =       'problemB.inp';
                baseD                   =       trunc( 1E9 ) + 9;

var             i , n , m               :       integer;
                res , tmp               :       int64;

function power( p : integer ) : int64;
        var     t       :       int64;
        begin
                if p = 0 then exit( 1 );
                if p = 1 then exit( 2 );
                t := power( p div 2 );
                result := ( t * t ) mod baseD;
                if odd( p ) then
                        result := ( result * 2 ) mod baseD;
        end;

begin
                readln( n , m );
                tmp := power( m ) mod baseD;
                res := 1;
                for i := 1 to n do
                        res := ( res * ( tmp - i ) ) mod baseD;
                writeln( res mod baseD );
end.


var
i:longint;
ind,n,min,m,ans,h,dl:int64;
begin
readln(n);
min:=1000000000;
for i:=1 to n do begin
    dl:=n div i;
    h:=i;
    ans:=dl*2+h*2;
    m:=n mod i;
    if m>0 then inc(anS,2);
    if ans<min then  begin min:=ans;    ind:=i; end;
end;
writeln(min);
//writeln(ind);
end.


var
  n, m: longint;

begin
  read(n, m);
  if n div 2 >= m then
    write(m + ord(m = 0))
  else
    write(n - m);
end.


program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const
  eps = 1e-8;

type
  Tpoint = record
    x, y : double;
  end;

var
  point : array[0..500] of Tpoint;
  ans : array[0..5001] of double;
  al, ar, bl, br : integer;

begin

  read(al, ar, bl, br);
  if (br + 1 >= al) then begin
    if br <= al * 2 + 2 then begin
      writeln('YES');
      halt;
    end;
  end;
  if (bl + 1 >= ar + 1) then begin
    if bl <= ar * 2 + 2 then begin
      writeln('YES');
      halt;
    end;
  end;

  writeln('NO');

end.


var n,m:longint;
begin
readln(n,m);
if n=m then writeln(n) else writeln(2);
end.


uses math;
var h,d,a,hy,ay,dy,hm,am,dm,hp,atk,def,min,kc: longint;

function ok(hy,ay,dy: longint) : boolean;
var s1,s2: longint;
begin
    if ay<=dm then exit(false);
    if am<=dy then exit(true);
    s1:=hm div (ay-dm);
    if hm mod (ay-dm) <> 0 then inc(s1);
    s2:=hy div (am-dy);
    if hy mod (am-dy) <> 0 then inc(s2);
    exit(s1<s2);
end;

begin
    readln(hy,ay,dy);
    readln(hm,am,dm);
    readln(h,a,d);
    min:=maxlongint;
    for hp:=1 to 1000 do
        for atk:=1 to 200 do
            for def:=1 to 200 do
            if (ok(hp,atk,def)) then
            begin
                kc:=max(0,hp-hy)*h+max(0,atk-ay)*a+max(0,def-dy)*d;
                if kc<min then min:=kc;
            end;
    write(min);
end.


var n,t,k:integer;
s,s1:string;
begin
k:=0;
readln(n,t);
readln(s);
s1:=s;
while k<>t do begin
for i:integer:=1 to n-1 do
if (s[i]='B') and (s[i+1]='G') then begin
s1[i]:='G';
s1[i+1]:='B';
end;
s:=s1;
k:=k+1;
end;
writeln(s);
end.


const
	gene='ACTG';
var
	s: string;
	n, c, num: integer;
function distance(x, y: char):integer;
begin
	if abs(ord(x)-ord(y)+1)<=13 then exit(abs(ord(x)-ord(y)))
	else exit(26-(abs(ord(x)-ord(y))))
end;

procedure count;
var
	i, j:integer;
begin
	for i:=1 to n-3 do
	begin
		c:=0;
		for j:=1 to 4 do inc(c, distance(s[i+j-1], gene[j]));
		if num>c then num:=c;
	end;
end;

begin
	readln(n);
	readln(s);
	num:=32767;
	count;
	write(num);
end.


var
  a, b, i, j, x: longint;

begin
  x := 1;
  readln(a, b);
  if a > b then
    j := b
  else j := a;
  for i := 1 to j do
    x := x * i;
  writeln(x);
end.


{R+,S+,Q+,I+,O-}
{$R-,S-,Q-,I-,O+}
var
  s: array [0..20010] of string;
  score,pred,last,ss,ff,first,second,len: array [0..30010] of longint;
  st: string;
  win: array [0..20010] of boolean;
  sq: array [0..33] of string;
  p,num,ll,rr,mid,nn,max,j,cur,sum,m,cf,cs,n,i,ii,jj: longint;
  cw: boolean;

procedure Sort(l,r:longint);
var
  i,j,pp,x,tt: longint;
  xx,tmp: string;
begin
  i:=l; j:=r;
  pp:=l+random(r-l+1);
  x:=len[pp]; xx:=s[pp];
  repeat
    while (len[i] < x) or (len[i] = x) and (s[i] < xx) do inc(i);
    while (x < len[j]) or (x = len[j]) and (xx < s[j]) do dec(j);
    if i <= j then
    begin
      tt:=len[i]; len[i]:=len[j]; len[j]:=tt;
      tmp:=s[i]; s[i]:=s[j]; s[j]:=tmp;
      inc(i); dec(j);
    end;
  until i > j;
  if l < j then Sort(l,j);
  if i < r then Sort(i,r);
end;

begin
  randseed:=8753;
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  readln(nn);
  n:=0;
  for i:=1 to nn do
  begin
    readln(sq[i]);
    for ii:=1 to length(sq[i]) do
      for jj:=ii to length(sq[i]) do
      begin
        inc(n);
        s[n]:=Copy(sq[i],ii,jj-ii+1);
        len[n]:=jj-ii+1;
      end;
  end;
  inc(n);
  s[n]:='';
  len[n]:=0;
  Sort(1,n);
  ii:=1;
  for i:=2 to n do
    if s[i] <> s[ii] then
    begin
      inc(ii);
      s[ii]:=s[i];
      len[ii]:=len[i];
    end;
  n:=ii;
  for i:=1 to n do
  begin
    max:=0; sum:=0;
    for j:=1 to length(s[i]) do
    begin
      cur:=Ord(s[i,j])-96;
      if cur > max then max:=cur;
      inc(sum,cur);
    end;
    score[i]:=max*sum;
    for j:=1 to nn do
      if Pos(s[i],sq[j]) > 0 then inc(score[i]);
  end;
  fillchar(last,sizeof(last),0);
  m:=0;
  for i:=2 to n do
    for j:=0 to 1 do
    begin
      if j = 0 then st:=Copy(s[i],2,len[i])
      else st:=Copy(s[i],1,len[i]-1);
      num:=0;
      ll:=1; rr:=i;
      while ll < rr do
      begin
        mid:=(ll+rr) shr 1;
        if s[mid] = st then
        begin
          num:=mid;
          break;
        end;
        if (len[mid] < len[i]-1) or (len[mid] = len[i]-1) and (s[mid] < st) then ll:=mid+1
        else rr:=mid-1;
      end;
      if s[ll] = st then num:=ll;
      if num > 0 then
      begin
        inc(m);
        ss[m]:=num;
        ff[m]:=i;
        pred[m]:=last[num];
        last[num]:=m;
      end;
    end;
  for i:=n downto 1 do
  begin
    win[i]:=False;
    first[i]:=0;
    second[i]:=0;
    j:=last[i];
    while j > 0 do
    begin
      p:=ff[j];
      cw:=not win[p];
      cf:=score[p]+second[p];
      cs:=first[p];
      if (cw > win[i]) or (cw = win[i]) and ((cf > first[i]) or (cf = first[i]) and (cs < second[i])) then
      begin
        win[i]:=cw;
        first[i]:=cf;
        second[i]:=cs;
      end;
      j:=pred[j];
    end;
  end;
  if win[1] then writeln('First')
  else writeln('Second');
  writeln(first[1],' ',second[1]);
  close(input);
  close(output);
end.


{$MODE OBJFPC}
Const
  Fi='';//471A.INP';
  Fo='';//471A.OUT';
Var Count:Array[0..10] of Integer;

Procedure Main;
Var i:Longint;
Begin
  For i:=1 to 10 do
    If Count[i]=1 then
      Begin
        Writeln('Bear');
        Exit;
      End
    Else
      If Count[i]=2 then
        Begin
          Writeln('Elephant');
          Exit;
        End;
End;

Procedure Enter;
Var x,i:Longint;
Begin
  For i:=1 to 6 do
    Begin
      Read(x);
      Inc(Count[x]);
    End;
  For i:=0 to 10 do
    If Count[i]>=4 then
      Begin
        Dec(Count[i],4);
        Main;
        Exit;
      End;
  Writeln('Alien');
End;

BEGIN
  Assign(Input,Fi); Reset(Input);
  Assign(Output,Fo); Rewrite(Output);

  Enter;

  Close(Input);
  Close(Output);
END.


 var n,m,k,x,y,min,max,ans,Kont,z,o: int64;
  i,j: integer;
   A:array[1..111,1..111] of int64;
   Vox:real;
   begin

   readln(n,m,k,x,y);
   o:=k;
   if n<>1 then
   Kont:=(k-m) div (((n-1)*m)*2)
   else
    begin
    min:=k div m;
    max:=min;
    if k mod m<>0 then
     max:=min+1;
    k:=k-min*m;
    if y<=k then
    ans:=min+1
    else
    ans:=min;
    writeln(max,' ',min,' ',ans);
    exit;
    end;

  z:=(Kont*(n-1)*m*2) div (2*N*M-2*m);

  K:=K-Kont*(n-1)*m*2-m;

  if k<=0 then
  begin
  for i:=1 to (k+m) do
   A[1,i]:=1;
  writeln(1,' ',0,' ',A[x,y]);
  exit;
  end;

  if z<>0 then
  for i:=1 to m do
  begin
  A[1,i]:=z+1;
  A[n,i]:=z;
  min:=z;
  max:=2*z;
  end
  else
  begin
  for i:=1 to m do
  A[1,i]:=1;
  end;

  for i:=2 to n-1 do
   for j:=1 to m do
   A[i,j]:=2*z;

  for i:=2 to n do
   for j:=1 to m do
    begin
    if k=0 then
    break;
    k:=k-1;
    A[i,j]:=A[i,j]+1;
    if A[i,j]>max then
    max:=A[i,j];
    end;

    for i:=n-1 downto 1 do
     for j:=1 to m do
      begin
      if k=0 then
      break;
      k:=k-1;
      A[i,j]:=A[i,j]+1;
      if A[i,j]>max then
      max:=A[i,j];
      end;

    if n=2 then
    max:=A[1,1];

    writeln(max,' ',A[n,m],' ',A[x,y]);

    end.


const fi='text.inp'; fo='text,out';
var   n,dem,i:longint;    sum:array[1..10000] of longint;   f2:text;
procedure   nhap;
var f1:text;
begin

        readln(n);

end;
procedure processlon;
var     i,m,tong1,tong:longint;
begin
        for i:=(n-90) to n do
         begin
                tong:=i;
                m:=i;
                while m<>0 do
                begin
                        tong1:=m mod 10;
                        m:=m div 10;
                        tong:=tong+tong1;
                end;
                if tong=n then
                 begin
                        inc(dem);
                        sum[dem]:=i;
                 end;

         end;
end;

procedure processbe;
var   i,m,tong1,tong,tongg:longint;
begin
        for i:=1 to n do
        begin
                tong:=i;
                m:=i;
                tongg:=0;
                while m<>0 do
                begin
                        tong1:=m mod 10;
                        m:=m div 10;
                        tongg:=tongg+tong1;
                end;
                tong:=tong+tongg;
                if tong=n then
                 begin
                        inc(dem);
                        sum[dem]:=i;
                 end;

         end;
end;
begin
        nhap;

        if n>80 then processlon else processbe;
        writeln(dem);
        for i:=1 to dem do writeln(sum[i]);

end.


{$R-,S-,Q-,I-,O+}
const co: int64 = 129581259982959;
var
  pw,h,hr: array [0..400010] of int64;
  d,bad,i,n: longint;
  ok: boolean;
  c: char;
  s: ansistring;

function pal(a,b:longint):boolean;
var
  direct,reverse: int64;
begin
  direct:=(h[b]-h[a-1]*pw[b-a+1])*pw[a-1];
  reverse:=hr[b]-hr[a-1];
  pal:=direct = reverse;
end;

begin
  readln(d);
  readln(s);
  n:=length(s);
  pw[0]:=1;
  for i:=1 to n do pw[i]:=pw[i-1]*co;
  h[1]:=0; hr[1]:=0;
  bad:=n;
  for i:=1 to n do
  begin
    h[i]:=h[i-1]*co+Ord(s[i]);
    hr[i]:=hr[i-1]+pw[i-1]*Ord(s[i]);
    if i >= d then
      if pal(i-d+1,i) then
      begin
        bad:=i;
        break;
      end;
    if i >= d+1 then
      if pal(i-d,i) then
      begin
        bad:=i;
        break;
      end;
  end;
  ok:=False;
  for i:=bad downto 1 do
  begin
    for c:=Chr(Ord(s[i])+1) to 'z' do
    begin
      s[i]:=c;
      h[i]:=h[i-1]*co+Ord(s[i]);
      hr[i]:=hr[i-1]+pw[i-1]*Ord(s[i]);
      if i >= d then
        if pal(i-d+1,i) then continue;
      if i >= d+1 then
        if pal(i-d,i) then continue;
      ok:=True;
      break;
    end;
    if ok then
    begin
      bad:=i;
      break;
    end;
  end;
  if not ok then writeln('Impossible') else
  begin
    for i:=bad+1 to n do
      for c:='a' to 'z' do
      begin
        s[i]:=c;
        h[i]:=h[i-1]*co+Ord(s[i]);
        hr[i]:=hr[i-1]+pw[i-1]*Ord(s[i]);
        if i >= d then
          if pal(i-d+1,i) then continue;
        if i >= d+1 then
          if pal(i-d,i) then continue;
        break;
      end;
    for i:=1 to n do write(s[i]);
    writeln;
  end;
end.


type arr = array[1..200009] of longint;
var n, k, i, lr, lo, lw, ans: longint;
    a, r, o, w: arr;
    s: string;

procedure write_arr(a:arr; len:longint);
var i:integer;
begin
    for i:=1 to len do write(a[i], ' ');
    writeln;
end;

procedure sort(var a:arr; len:longint);
    procedure _sort(l, r: longint);
    var i, j, x, tmp: longint;
    begin
        // writeln(l, ' ', r);
        i:=l; j:=r; x:=a[(l+r) div 2];
        repeat
            while (a[i] > x) do inc(i);
            while (x > a[j]) do dec(j);
            if (i <= j) then
            begin
                tmp := a[i];
                a[i] := a[j];
                a[j] := tmp;
                inc(i);
                dec(j);
            end;
        until (i > j);
        if (l < j) then _sort(l, j);
        if (i < r) then _sort(i, r);
    end;
begin
    _sort(1, len);
end;

function get_o_with(a:arr):longint;
var res, i, j, cnt:longint;
begin
    res := a[1] + o[1];
    i := 2;
    j := 2;
    for cnt := 3 to k do
    begin
        if ((j > lo) or (a[i] > o[j])) then
        begin
            inc(res, a[i]);
            inc(i);
        end else
        begin
            inc(res, o[j]);
            inc(j);
        end;
    end;
    exit(res);
end;

function max(a, b:longint):longint;
begin
    if (a > b) then exit(a) else exit(b);
end;

begin
    readln(n, k);
    for i:=1 to n do read(a[i]);
    readln; readln(s);

    lr:=0; lo:=0; lw:=0;
    for i:=1 to n do
        if (s[i] = 'R') then
        begin
            inc(lr);
            r[lr]:=a[i];
        end else
        if (s[i] = 'O') then
        begin
            inc(lo);
            o[lo]:=a[i];
        end else
        if (s[i] = 'W') then
        begin
            inc(lw);
            w[lw]:=a[i];
        end;

    if ((k=1) or (lo=0) or (lr+lw=0) or ((lo+lr<k) and (lo+lw<k))) then
    begin
        writeln(-1);
        halt;
    end;
    sort(r, lr); // write_arr(r, lr);
    sort(o, lo); // write_arr(o, lo);
    sort(w, lw); // write_arr(w, lw);

    ans := -1;
    if ((lr > 0) and (lo + lr >= k)) then ans := max(ans, get_o_with(r));
    if ((lw > 0) and (lo + lw >= k)) then ans := max(ans, get_o_with(w));
    writeln(ans);
end.


const   p=51123987;
var
        n,i,j,a,b,c,ans:longint;
        f:array[0..150,0..52,0..52,0..52] of longint;
        nn:array[0..3,0..151] of longint;
        s:string;
begin
        readln(n);
        readln(s);
        for i:=n downto 1 do begin
                for j:=1 to 3 do nn[j,i]:=nn[j,i+1];
                case s[i] of
                        'a':nn[1,i]:=i;
                        'b':nn[2,i]:=i;
                        'c':nn[3,i]:=i;
                end;
        end;
        f[1,0,0,0]:=1;
        for i:=1 to n do begin
                for a:=0 to n div 3+1 do begin
                        for b:=0 to n div 3+1 do begin
                                for c:=0 to n div 3+1 do begin
                                        if f[i,a,b,c]=0 then continue;
                                        if nn[1,i]<>0 then f[nn[1,i],a+1,b,c]:=(f[nn[1,i],a+1,b,c]+f[i,a,b,c]) mod p;
                                        if nn[2,i]<>0 then f[nn[2,i],a,b+1,c]:=(f[nn[2,i],a,b+1,c]+f[i,a,b,c]) mod p;
                                        if nn[3,i]<>0 then f[nn[3,i],a,b,c+1]:=(f[nn[3,i],a,b,c+1]+f[i,a,b,c]) mod p;
                                        if a+b+c<>n then continue;
                                        if (abs(a-b)>1) or (abs(a-c)>1) or (abs(b-c)>1) then continue;
                                        ans:=(ans+f[i,a,b,c]) mod p;
                                end;
                        end;
                end;
        end;
        writeln(ans);
end.


var s: string;
m,k,ak,i: longint;
begin
readln (s);
k:=1;
ak:=1;
m:=length(s);
if m mod 2 = 0 then
   begin
   for i:=1 to m div 2 do
       begin
       if s[i]<>s[m-i+1] then k:=0;
       if (i>1) and (s[i]<>s[i-1]) then ak:=0;
       end;
   if k=0 then writeln (m);
   if (k=1) and (ak=1) then writeln ('0');
   if (k=1) and (ak=0) then writeln (m-1);
   end;
if m mod 2 = 1 then
   begin
   for i:=1 to m div 2 do
       begin
       if s[i]<>s[m-i+1] then k:=0;
       if (i<(m+1) div 2) and (s[i]<>s[i+1]) then ak:=0;
       end;
   if k=0 then writeln (m);
   if (k=1) and (ak=1) then writeln ('0');
   if (k=1) and (ak=0) then writeln (m-1);
   end;
end.


var
s:string;
i,n,kr,kb,ky,kg:integer;
k:array[1..4] of integer;
begin
read(s);
for i:=1 to  length(s) div 4 do begin
n:=(i-1)*4;
if s[n+1] = '!' then inc(k[1]);
if s[n+2] = '!' then inc(k[2]);
if s[n+3] = '!' then inc(k[3]);
if s[n+4] = '!' then inc(k[4]);
end;
n:=length(s) mod 4;
case n of
1: if s[length(s)] = '!' then inc(k[1]);
2: begin if s[length(s)] = '!' then inc(k[2]); if s[length(s)-1] = '!' then inc(k[1]);  end ;
3: begin if s[length(s)] = '!' then inc(k[3]); if s[length(s)-1] = '!' then inc(k[2]); if s[length(s)-2] = '!' then inc(k[1]);   end;
end;
if pos('R',s) <> 0 then kr:= pos('R',s) mod 4; if kr = 0 then kr:=4;
if pos('B',s) <> 0 then kb:= pos('B',s) mod 4; if kb = 0 then kb:=4;
if pos('Y',s) <> 0 then ky:= pos('Y',s) mod 4; if ky = 0 then ky:=4;
if pos('G',s) <> 0 then kg:= pos('G',s) mod 4; if kg = 0 then kg:=4;
write(k[kr],' ',k[kb],' ',k[ky],' ',k[kg]);
end.


var a:array[1..100] of longint;
n,m,i,j,max,d:longint;
begin
        read(n,m);
        for i:=1 to n do read(a[i]);

        for i:=1 to n do
        begin
         if a[i]  mod m=0 then a[i]:=a[i]-1;
        if (a[i] div m)>=max then
        begin
         max:=a[i] div m;
         d:=i;
        end;

   end;  write(d);
end.