Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $$$x$$$, Egor on the floor $$$y$$$ (not on the same floor with Masha).The house has a staircase and an elevator. If Masha uses the stairs, it takes $$$t_1$$$ seconds for her to walk between adjacent floors (in each direction). The elevator passes between adjacent floors (in each way) in $$$t_2$$$ seconds. The elevator moves with doors closed. The elevator spends $$$t_3$$$ seconds to open or close the doors. We can assume that time is not spent on any action except moving between adjacent floors and waiting for the doors to open or close. If Masha uses the elevator, it immediately goes directly to the desired floor.Coming out of the apartment on her floor, Masha noticed that the elevator is now on the floor $$$z$$$ and has closed doors. Now she has to choose whether to use the stairs or use the elevator. If the time that Masha needs to get to the Egor's floor by the stairs is strictly less than the time it will take her using the elevator, then she will use the stairs, otherwise she will choose the elevator.Help Mary to understand whether to use the elevator or the stairs.

The only line contains six integers $$$x$$$, $$$y$$$, $$$z$$$, $$$t_1$$$, $$$t_2$$$, $$$t_3$$$ ($$$1 \leq x, y, z, t_1, t_2, t_3 \leq 1000$$$) — the floor Masha is at, the floor Masha wants to get to, the floor the elevator is located on, the time it takes Masha to pass between two floors by stairs, the time it takes the elevator to pass between two floors and the time it takes for the elevator to close or open the doors. It is guaranteed that $$$x \ne y$$$.

If the time it will take to use the elevator is not greater than the time it will take to use the stairs, print «YES» (without quotes), otherwise print «NO> (without quotes). You can print each letter in any case (upper or lower).

NoteIn the first example:If Masha goes by the stairs, the time she spends is $$$4 \cdot 4 = 16$$$, because she has to go $$$4$$$ times between adjacent floors and each time she spends $$$4$$$ seconds. If she chooses the elevator, she will have to wait $$$2$$$ seconds while the elevator leaves the $$$4$$$-th floor and goes to the $$$5$$$-th. After that the doors will be opening for another $$$1$$$ second. Then Masha will enter the elevator, and she will have to wait for $$$1$$$ second for the doors closing. Next, the elevator will spend $$$4 \cdot 2 = 8$$$ seconds going from the $$$5$$$-th floor to the $$$1$$$-st, because the elevator has to pass $$$4$$$ times between adjacent floors and spends $$$2$$$ seconds each time. And finally, it will take another $$$1$$$ second before the doors are open and Masha can come out. Thus, all the way by elevator will take $$$2 + 1 + 1 + 8 + 1 = 13$$$ seconds, which is less than $$$16$$$ seconds, so Masha has to choose the elevator.In the second example, it is more profitable for Masha to use the stairs, because it will take $$$13$$$ seconds to use the elevator, that is more than the $$$10$$$ seconds it will takes to go by foot.In the third example, the time it takes to use the elevator is equal to the time it takes to walk up by the stairs, and is equal to $$$12$$$ seconds. That means Masha will take the elevator.

var x,y,z,t1,t2,t3,kq1,kq2:longint;
begin
        readln(x,y,z,t1,t2,t3);
        kq1:=abs(x-y)*t1;
        if z <> x then kq2:=abs(z-x)*t2+2*t3
        else
        kq2:=2*t3;
        kq2:=kq2+abs(x-y)*t2+t3;
        if kq1 < kq2 then writeln('NO')
        else writeln('YES');
        readln;
end.

Program ElevatororStairs;
uses math;
var x,y,z,t1,t2,t3:integer; d1,d2:int64;
begin   //assign(input,'1054A.inp'); reset(input);
        //assign(output,'1054A.out'); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        d1:=abs(x-y)*t1; d2:=(abs(x-y)+abs(x-z))*t2+3*t3;
        if d1>=d2 then writeln('YES')
        else writeln('NO');
        //close(input); close(output);
end.

var
  x, y, z, t1, t2, t3: integer;
  d_et, t_lestn, t_lift:integer;

begin
  readln(x, y, z, t1, t2, t3);
  d_et:=abs(x-y);
  t_lestn:=d_et*t1;
  t_lift:=t3*3+abs(z-x)*t2+d_et*t2;
  if t_lift<=t_lestn then writeln('YES') else writeln('NO');
end.

uses    math;
const   fi='1054A.INP'; fo='1054A.out';
var     res1,res2,x,y,z,t1,t2,t3: longint;
begin
    //    assign(input,fi); reset(input);
    //    assign(output,fo); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        res1:=t1*abs(x-y);
        res2:=abs(x-z)*t2+3*t3+t2*abs(x-y);
        if res1<res2 then writeln('NO') else writeln('YES');
end.

var a,b,x,y,z,t1,t2,t3:longint;
begin
 read(x,y,z,t1,t2,t3);
 a:=abs(x-y)*t1;
 b:=(abs(x-y)+abs(z-x))*t2+3*t3;
 if a<b then write('NO') else write('YES');
end.

var x,y,z,t1,t2,t3, tm, tl :integer;
begin
Read(x,y,z,t1,t2,t3);
tm:= abs(x-y)*t1;
tl:=abs(x-z)*t2+abs(x-y)*t2+3*t3;
if tl<=tm then write('Yes') else write('No');
end.

program a;
var
	x, y, z, t1, t2, t3:word;
	lift, stairs:cardinal;
begin
	readln(x, y, z, t1, t2, t3);
	stairs:=abs(x-y)*t1;
	lift:=abs(x-z)*t2+2*t3+abs(x-y)*t2+t3;
	if(stairs<lift)then writeln('no')
	else writeln('yes')
end.

 program abc;
var x,y,z,t1,t2,t3,tl,ts:integer;
begin
readln(x,y,z,t1,t2,t3);
ts:=(abs(x-y))*t1;
tl:=t3+((abs(z-x))*t2)+t3+((abs(x-y)*t2))+t3;
if tl<=ts then
begin
writeln('yes');
end
 else writeln('no');
readln;
end.

var
x,y,z,t1,t2,t3,ans,ans1:longint;
begin
readln(x,y,z,t1,t2,t3);
ans:=t1*abs(x-y);
ans1:=2*t3+t2*(abs(z-x))+t2*(abs(x-y))+t3;
if anS>=ans1 then writeln('YES')
else
writeln('NO');
end.

uses    math;
var     res1,res2,x,y,z,t1,t2,t3: longint;
begin
        readln(x,y,z,t1,t2,t3);
        res1:=t1*abs(x-y);
        res2:=abs(x-z)*t2+3*t3+t2*abs(x-y);
        if res1<res2 then writeln('NO') else writeln('YES');
end.

var ev,el,l,t1,t2,td,p1,p2:int64;
begin
read(el,ev,l,t1,t2,td);
p2:=td*3+(abs(el-ev)*t2)+abs(el-l)*t2;
p1:=(abs(el-ev)*t1);
if p2<=p1 then write('YES') else write('NO');
end.

var x,y,z,t1,t2,t3:int64;
begin
  readln(x,y,z,t1,t2,t3);
  if abs((x-y))*t2+abs((x-z))*t2+3*t3<=abs(x-y)*t1 then
    writeln('YES')
  else
    writeln('NO');
end.

program tz;
var x,y,z,t1,t2,t3,l,e:integer;
begin
readln (x,y,z,t1,t2,t3);
l:=abs(x-y)*t1;
e:=(abs(x-z)+abs(x-y))*t2+3*t3;
if e<=l then writeln ('YES') else writeln ('NO');
end.

var z,x,stair,elevator,y,t1,t2,t3:int64;
begin
        read(x,y,z,t1,t2,t3);
        stair:=abs(x-y)*t1;
        elevator:=abs(z-x)*t2+abs(x-y)*t2+3*t3;
        if stair>=elevator then write('YES')
        else write('NO');
end.

Program Elevator;
Var
	x, y, z, t1, t2, t3: integer;
	eTime, sTime: integer;

Begin
    Readln(x, y, z, t1, t2, t3);

    eTime := Abs(z-x)*t2 + t3 + t3 + Abs(y-x)*t2 + t3;
    sTime := Abs(y-x)*t1;

    If (eTime > sTime) then
    	Writeln('NO')
    Else
    	Writeln('YES');

End.

Var x , y , z , t1 , t2 , t3 , tmp , tam : Longint;
Begin
Readln(x , y , z , t1 , t2 , t3);
tam := abs(x - y) * t1;
tmp := abs(x - z) * t2 + 3 * t3 + abs(x - y) * t2;
If tam < tmp then Writeln('NO') else Writeln('YES');
End.

var  x,y,z,t1,t2,t3:int64;
begin
read (x,y,z,t1,t2,t3);
if ((abs(x-y)+abs(x-z))*t2+t3*3)<=abs(x-y)*t1
then writeln ('YES')
else writeln ('NO');
end.

var d,e,f,z,x,y,a,b,c,t1,t2,t3: integer;
begin
  read(a,b,c,t1,t2,t3);
  d:=abs(c-a)*t2+abs(a-b)*t2+3*t3;
  e:=abs(a-b)*t1;
  if (abs(c-a)*t2+abs(a-b)*t2+3*t3)<=(abs(a-b)*t1) then
    writeln('yes')
  else
    writeln('no');
end.

var
	x, y, z, t1, t2, t3, lift, stairs: integer;
	s: string;

begin

	readln(x, y, z, t1, t2, t3);
	lift := (abs(z - x)) * t2 + 2 * t3 + (abs(y - x)) * t2 + t3;
	stairs := t1 * (abs(x - y));

	if (lift <= stairs) then
		writeln('YES')
	else
		writeln('NO');

end.

var
  a, b, c, d, e, f, g, h, i, j, k, r, l, fl: int64;
  arr: array [-1000..200000] of int64;
  ar: array [-1000..200000] of int64;
  arrr: array [1..200000] of int64;
  kol: double;
  s, s1, s2: string;

begin
  readln(a, b, c ,d ,e ,f);
  if abs (a-b)*d<(abs(a-c)+abs(a-b))*e+3*f then write ('NO')
  else
  write ('YES');
end.

var x,y,t1,t2,t3,z : integer;
begin
read(x); // Этаж маши
read(y); // этаж егора
read(z); // этаж лифта
read(t1); // скорость маша
read(t2); // скорость лифта
read(t3); // двери лифта

if abs(x-y)*t1 >= abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('YES') else write('NO');

end.

var x,y,z,t1,t2,t3:integer;
 begin
 readln(x,y,z,t1,t2,t3);
 if ((abs(y-x)+abs(x-z))*t2+3*t3)>(abs(y-x)*t1) then
  writeln('no')
 else
  writeln('yes');
 end.

var
  x, y, z, t1, t2, t3, h, d: integer;

begin
  readln(x, y, z, t1, t2, t3);// номер этажа, на котором находится Маша, номер
  //этажа, на который хочет попасть Маша, номер этажа, на котором находится лифт,
  //время, за которое Маша проходит между соседними этажами по лестнице, время,
  //за которое лифт проезжает между этажами и время, за которое открываются и
  //закрываются двери у лифта, соответственно.

  if x > y then
    h := (x - y) * t1
  else
    h := (y - x) * t1;

  if x > y then
    if x >= z then
      d := (x - z) * t2 + t3 + t3 + (x - y) * t2 + t3
    else
      d := (z - x) * t2 + t3 + t3 + (x - y) * t2 + t3;

  if x < y then
    if x >= z then
      d := (x - z) * t2 + t3 + t3 + (y - x) * t2 + t3
    else
      d := (z - x) * t2 + t3 + t3 + (y - x) * t2 + t3;

  if d <= h then writeln('YES')
  else
    writeln('NO');

end.

program xxx;
var x,y,z,t1,t2,t3,v1,v2:integer;

begin

read(x,y,z,t1,t2,t3);

v1:=abs(z-x)*t2+abs(y-x)*t2+3*t3;
v2:=abs(y-x)*t1;

if v1>v2 then

writeln('NO')

else

writeln('YES');

end.

var
 x, y, z, t1, t2, t3, tl, tp: integer;
begin
 read(x, y, z, t1, t2, t3);
 tl := abs((x - z))*t2 + t3 + t3 + abs((x - y))*t2 + t3;
 tp := abs((x - y))*t1;
 if tl <= tp then writeln('YES')
 else writeln('NO');

end.

program gg;
var x,y,z,t1,t2,t3:int64;
begin
read(x,y,z,t1,t2,t3);
if abs(y-x)*t1 < ((abs(y-x)+abs(x-z))*t2+t3*3) then
write('NO')
else
write('YES');
end.

Var x,y,z,t1,t2,t3,time1,time2:integer;
Begin
Read(x,y,z,t1,t2,t3);
time1:=abs(y-x)*t1;
time2:=((abs(z-x))*t2)+((abs(y-x))*t2)+(t3*3);
If time1>=time2 then writeln('YES')
else writeln('NO');
end.

Var
    x, y, z, t1, t2, t3: LongInt;

Begin
    Read(x, y, z, t1, t2, t3);
    If (abs(x - y))*t1 < (abs(x - z) + abs(y - x))*t2 + 3*t3 then
        Write('NO')
    Else
        Write('YES')
End.

var
x,y,z,t1,t2,t3,p,l:integer;
begin
readln(x,y,z,t1,t2,t3);
p:=abs(x-y)*t1;
l:=abs(x-z)*t2+abs(x-y)*t2+3*t3;
if p<l then writeln('NO') else writeln('YES');
end.

program evklid;
var x,y,z,t,a,b,t1,t2: longint;
begin
read(x,y,z,t,a,b);
t1:=abs(z-x)*a+b*3+abs(x-y)*a;
t2:=abs(y-x)*t;
if t1<=t2 then
writeln('YES')
else
writeln('NO');
end.

var
  x, y, z, t1, t2, t3, l, lu: integer;

begin
  read(x, y, z, t1, t2, t3);
  if x > y then
    l := t1 * (x - y)
  else
    l := t1 * (y - x);
  if z > x then
    lu := t2 * (z - x) + t3 * 3
  else
    lu := t2 * (x - z) + t3 * 3;
  if x > y then
    lu := lu + t2 * (x - y)
  else
    lu := lu + t2 * (y - x);
  if lu > l then
    write('NO')
  else
    write('YES')
end.

program nA;
var
  x,y,z,t1,t2,t3,t4,a,b,c,d:integer;
begin
  read(x,y,z,t1,t2,t3);
  a:=abs(z-x);
  t4:=t2*a;
  b:=abs(x-y);
  c:=3*t3+t2*b+t4;
  d:=b*t1;
  if c>d then
   write('NO')
  else
   write('YES');
end.

var x, y, z, t1, t2, t3:integer;

begin
  readln(x, y, z, t1, t2, t3);
  if (abs(z-x))*t2+3*t3+(abs(y-x))*t2 <= (abs(y-x))*t1 then
    write('YES')
  else
    write('NO');
end.

var x,y,z,t1,t2,t3,ph,pzd:integer;

begin
  readln(x,y,z,t1,t2,t3);
  ph:=abs(x-y)*t1;
  pzd:=((abs(x-z)*t2)+t3)+(t2*abs(x-y)+t3)+t3;
  if ph=pzd then write('YES') else
  if pzd<ph then write('YES') else write('NO');
end.

Program p;
var x, y, z, t1, t2, t3: integer;

begin
read(x, y, z, t1, t2, t3);
if t3*3+(abs(x-y)+abs(x-z))*t2<=abs(x-y)*t1 then write('YES')
  else write('NO')
end.

program HelloWorld;
var x,y,z,t1,t2,t3,tpod,tles,etag,etagl:integer;
begin
   read(x,y,z,t1,t2,t3);
   if x> y then etag:=x-y else etag:=y-x;
   if x> z then etagl:=x-z else etagl:=z-x;
   tpod:=t3*3+t2*(etagl+etag);
   tles:=t1*etag;
   if tpod <= tles then write('YES')else write('NO');
   end.

var x,y,z,t1,t2,t3:integer;
begin
readln(x,y,z,t1,t2,t3);
if ((abs(z-x)*t2+abs(x-y)*t2+3*t3)<(abs(x-y)*t1))
   or
   ((abs(z-x)*t2+abs(x-y)*t2+3*t3)=(abs(x-y)*t1))
   then writeln('YES') else writeln('NO');
   end.

var x,y,z,t1,t2,t3,q1,q2:integer;
begin
 readln(x,y,z,t1,t2,t3);
 q1:=abs(x-y)*t1;
 q2:=abs(z-x)*t2+3*t3+abs(x-y)*t2;
  if q2<=q1 then writeln('YES')
  else writeln('NO');
end.

var
     le,li,x,y,z,t1,t2,t3: integer;
begin
read(x,y,z,t1,t2,t3);
le:=t1*abs(x-y);
li:=3*t3+t2*abs(z-x)+t2*abs(x-y);
if li<=le then write('yes') else write('no');
end.

program q;
  var a,n,m,g,k,j,i,x,y,z,t1,t2,t3:integer;
begin
  readln(x,y,z,t1,t2,t3);
  while (x<1) and (x>1000) do
  readln(x);
  while (y<1) and (y>1000) do
  readln(y);
  while x=y do
  readln(x,y);
  while (z<1) and (z>1000) do
  readln(z);
  while (t1<1) and (t1>1000) do
  readln(t1);
  while (t2<1) and (t2>1000) do
  readln(t2);
  while (t3<1) and (t3>1000) do
  readln(t3);
  if x>y then i:=x-y
  else i:=y-x;
  if x>z then m:=x-z
  else m:=z-x;
  g:=m*t2;
  a:=i*t1;
  k:=t3*3;
  j:=i*t2;
  n:=k+j+g;
  if a<n then writeln('NO')
  else writeln('YES');
end.

var
  x, y, z, t1, t2, t3: int64;

begin
  read(x, y, z, t1, t2, t3);
  if abs(x-z) * t2 + 3 * t3 + abs(x-y) * t2 <= abs(x-y) * t1 then
    write('YES')
  else
    write('NO');
end.

                          const eps=0.000000001;  besk1=200000008;  nnn=4600000;
              modul={1000000007}998244353 ;
   besk=4000000000000000000;
   label 22,1,2,3,4;
    type    real=extended;   double=extended;
    mas=array [-300000..nnn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10000..nnn] of longint;mass1=^mass;
    var xx,yy,zz,left,right,up,down,jjj,l,r,aa,bb,cc,sum,mnog,nn,t3,t4,t5,t6,posmax,tmax,kold,kk,d,n,j2,ttt,ppp,kol,sq,h,pmin,pmax,limit,posi,posj,diam,oldt,ot1,time,pos,ll,rr,posx,posy,gr,dloch,newdl,oldn,oldm,ost,ot,p1,p2,p3,p4,znamzz,kolperiod,znam,tperiod,start,finish,kol1,kol2,lavel,x0,p0,t2,t1,jj,w,ii,ogr,q,p,pp,tt,oldtt,qq,qq1,qq2,q1,q2,imax,t,nm,m,smin,cen:int64;
   i2,i3,step2,k1,k2,pp0,mask,k,i1,j1,step1, step, i,j:longint;
   a,zsum,y,x,z:array[-200000..4350012] of int64;
    prob1,prob2,prob3,pr1new,pr2new,pr3new,pr1,pr2,pr3:zap;
    iii,oldpos,finot,vv,znak:int64;
    aold:mas;
    v,ans,ccc,dist,alpha,phi:extended;
    zzan:array[-1..2003,-1..2003] of boolean;
    sumkonfig,konfig:array[-1000..200000,-1..10] of int64;
    xleft,xright,xplus,xminus,px,py,xc,yc,xxc,yyc:extended;
    del:array[-1..100001,-1..150] of longint;
    z0,num,y1,z1,z2,kolnul,fact,next,prev,str,s,name,dnew, voltay,c,day,b:mas;
    zzz:array[0..125000000] of byte;
    aaa,bbb,x1,x2:extended;
    pole:array[-10..2002,-10..2005] of char;
    ppole,ddl,ddr,dd3,dd4:array[-10..4200,-10..2020] of int64;
    dd,ddnew:array[-1..12,-1..12,0..200,0..3] of int64;
   newzan,marked,zanx,zany:array[-1000000..2000000] of boolean;
    sss1,sss2:string;
    def,stepen,koled,dl,och,newoch,place,newnabor,stoim,nabor:array[-10..200005] of int64;
     zanleft,zanright,zan,fl:array[-100000..10000000] of boolean;
    ss1,ss2,ss:string;ch,ch1,ch2:char;
    pr,hesh,numright,dr: array [-10..1060,-10..1060] of extended;
    s3,s2,s1:array[-100..500000] of string;

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

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

  function min(a,b:int64):int64;
begin min:=a; if b<a then min:=b;   end;

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 fl:=false;

   prost:=fl;
 end;

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

     end;

end;

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

         end;

     end;

end;

 function 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 ssum(ll,rr:int64):int64;
var p,t,ot:int64;
begin
    p:=z[rr]-z[ll-1];
    ot:=p;

   ssum:=ot;
end;

function good(i,j:int64):boolean;
begin
  if (i>0)and(i<=n)and(j>0)and(j<=n) then good:=true else good:=false;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
      readln(xx,yy,zz,t1,t2,t3);
      p1:=abs(xx-yy)*t1;
      p2:=(abs(xx-yy)+abs(zz-xx))*t2+3*t3;

     { writeln(p1,' ',p2);
     } if not (p1<p2) then write('YES') else write('NO');

1:             close(output);
end.

var x,y,z,t1,t2,t3,kq1,kq2:longint;
begin
        readln(x,y,z,t1,t2,t3);
        kq1:=abs(x-y)*t1;
        if z <> x then kq2:=abs(z-x)*t2+2
        else
        kq2:=2;
        kq2:=kq2+abs(x-y)*t2+1;
        if kq1 < kq2 then writeln('NO')
        else writeln('YES');
        readln;
end.

var x,y,z,t1,t2,t3,kq1,kq2:longint;
begin
        readln(x,y,z,t1,t2,t3);
        kq1:=abs(x-y)*t1;
        if z <> x then kq2:=abs(z-x)*t2+2*t3
        else
        kq2:=2;
        kq2:=kq2+abs(x-y)*t2+t3;
        if kq1 < kq2 then writeln('NO')
        else writeln('YES');
        readln;
end.

Program ElevatororStairs;
uses math;
var x,y,z,t1,t2,t3:integer; d1,d2:int64;
begin   //assign(input,'1054A.inp'); reset(input);
        //assign(output,'1054A.out'); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        d1:=abs(x-y)*t1; d2:=abs(2*x-y-z)*t2+3*t3;
        if d1>d2 then writeln('YES')
        else writeln('NO');
        //close(input); close(output);
end.

Program ElevatororStairs;
uses math;
var x,y,z,t1,t2,t3:integer; d1,d2:int64;
begin   //assign(input,'1054A.inp'); reset(input);
        //assign(output,'1054A.out'); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        d1:=abs(x-y)*t1; d2:=(abs(x-y)+abs(x-z))*t2+3*t3;
        if d1>d2 then writeln('YES')
        else writeln('NO');
        //close(input); close(output);
end.

Program ElevatororStairs;
uses math;
var x,y,z,t1,t2,t3:integer; d1,d2:int64;
begin   //assign(input,'1054A.inp'); reset(input);
        //assign(output,'1054A.out'); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        d1:=abs(x-y)*t1; d2:=abs(2*x-y-z)*t2+3*t3;
        if d1>=d2 then writeln('YES')
        else writeln('NO');
        //close(input); close(output);
end.

uses    math;
const   fi='1054A.INP'; fo='1054A.out';
var     res1,res2,x,y,z,t1,t2,t3: longint;
begin
    //    assign(input,fi); reset(input);
    //    assign(output,fo); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        res1:=t1*abs(x-y);
        res2:=abs(x-z)+3*t3+t2*(x-y);
        if res1<res2 then writeln('NO') else writeln('YES');
end.

uses    math;
const   fi='1054A.INP'; fo='1054A.out';
var     res1,res2,x,y,z,t1,t2,t3: longint;
begin
    //    assign(input,fi); reset(input);
    //    assign(output,fo); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        res1:=t1*abs(x-y);
        res2:=abs(x-z)+3*t3+t2*abs(x-y);
        if res1<res2 then writeln('NO') else writeln('YES');
end.

uses    math;
const   fi='1054A.INP'; fo='1054A.out';
var     x,y,z,t1,t2,t3: longint;
begin
       // assign(input,fi); reset(input);
        // assign(output,fo); rewrite(output);
        readln(x,y,z,t1,t2,t3);
        writeln(min(t1*abs(x-y), abs(x-z)+3*t3+t2*(x-y)));
end.

program a;
var
	x, y, z, t1, t2, t3:word;
	lift, stairs:cardinal;
begin
	readln(x, y, z, t1, t2, t3);
	stairs:=abs(x-y)*t1;
	if(x=z)then
		lift:=t3
	else
		lift:=abs(x-z)*t2+2*t3;
	lift+=abs(x-y)*t2+t3;
	if(stairs<lift)then writeln('no')
	else writeln('yes')
end.

 program abc;
var x,y,z,t1,t2,t3,tl,ts:integer;
begin
readln(x,y,z,t1,t2,t3);
ts:=(abs(x-y))*t1;
tl:=t3+((abs(z-x))*t2)+t3+((abs(x-y)*t2))+t3;
if tl<=ts then
begin
writeln('yes');
end
 else writeln('no');
writeln(tl,'  ',ts);
readln;
end.

 program abc;
var x,y,z,t1,t2,t3,tl,ts:integer;
begin
writeln('x,y,z,t1,t2,t3');
readln(x,y,z,t1,t2,t3);
ts:=(abs(x-y))*t1;
tl:=t3+((abs(z-x))*t2)+t3+((abs(x-y)*t2))+t3;
if tl<=ts then
begin
writeln('yes');
end
 else writeln('no');
writeln(tl,'  ',ts);
readln;
end.

var ev,el,l,t1,t2,td,p1,p2:int64;
begin
read(el,ev,l,t1,t2,td);
p2:=td*3+(abs(el-ev)*t2)+abs(el-l);
p1:=(abs(el-ev)*t1);
if p2<=p1 then write('YES') else write('NO');
end.

Var x , y , z , t1 , t2 , t3 , tmp , tam : Longint;
Begin
Readln(x , y , z , t1 , t2 , t3);
tam := abs(x - y) * t1;
tmp := abs(x - z) * t2 + 2 * t3 + abs(x - y) * t2;
If tam < tmp then Writeln('NO') else Writeln('YES');
End.

var d,a,b,c,t1,t2,t3: integer;
begin
  read(a,b,c,t1,t2,t3);
  if (abs(c-a)*t2+3*t3+abs(b-abs(c-(c-a)))*t2)<(c*t1) then
    writeln('yes')
  else
    writeln('no');
end.

var d,a,b,c,t1,t2,t3: integer;
begin
  read(a,b,c,t1,t2,t3);
  if (abs(c-a)*t2+2*t3+abs(b-abs(c-(c-a)))*t2)<(c*t1) then
    writeln('yes')
  else
    writeln('no');
end.

var
	x, y, z, t1, t2, t3, lift, stairs: integer;
	s: string;

begin

	readln(x, y, z, t1, t2, t3);
	lift := (abs(z - x)) * t2 + 2 * t3 + (abs(y - x)) * t2 + t3;
	stairs := t1 * (abs(x - y));

	if (lift < stairs) then
		writeln('YES')
	else
		writeln('NO');

end.

var
  a, b, c, d, e, f, g, h, i, j, k, r, l, fl: int64;
  arr: array [-1000..200000] of int64;
  ar: array [-1000..200000] of int64;
  arrr: array [1..200000] of int64;
  kol: double;
  s, s1, s2: string;

begin
  readln(a, b, c ,d ,e ,f);
  if abs (a-b)*d<(abs(a-c)+abs(a-b))*e+2*f then write ('NO')
  else
  write ('YES');
end.

var x,y,z,t1,t2,t3,t,tt : integer;
begin
read(x,y,z,t1,t2,t3);

if x=z then
t:= 2*t3+abs(x-y)*t2+t3;

if x > z then
t:=(x-z)*t2+2*t3;
  if x>y then
  t:=t+t2*(x-y)+t3;
  if x<y then
  t:=t+t2*(y-x)+t3;

if x<z then
  t:=(z-x)*t2+2*t3;
  if x>y then
  t:=t+t2*(x-y)+t3;

  if x<y then
  t:=t+t2*(y-x)+t3;
  if abs(x-z)*t1 > tt then write('YES')
  else Write('NO');
  end.

var x,y,t1,t2,t3,z : integer;
begin
read(x);
read(y);
read(t1);
read(t2);
read(t3);
read(z);

if abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)+t3 then write('NO') else write('YES');

end.

var x,y,z,t1,t2,t3,t,tt : integer;
begin
read(x,y,z,t1,t2,t3);

if x=z then
t:= 2*t3+abs(x-y)*t2+t3;

if x > z then
t:=(x-z)*t2+2*t3;
  if x>y then
  t:=t+t2*(x-y)+t3;
  if x<y then
  t:=t+t2*(y-x)+t3;

if x<z then
  t:=(z-x)*t2+2*t3;
  if x>y then
  t:=t+t2*(x-y)+t3;
   if x<y then
  t:=t+t2*(y-x)+t3;

  if abs(x-z)*t1 > t then write('NO')
  else Write('YES');
  end.

var x,y,t1,t2,t3,z : integer;
begin
read(x);
read(y);
read(t1);
read(t2);
read(t3);
read(z);

if abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)+t3 then write('YES') else write('NO');

end.

var x,y,t1,t2,t3,z : integer;
begin
read(x); // Этаж маши
read(y); // этаж егора
read(z); // этаж лифта
read(t1); // скорость маша
read(t2); // скорость лифта
read(t3); // двери лифта

if abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('YES') else write('NO');

end.

var x,y,t1,t2,t3,z : integer;
begin
read(x); // Этаж маши
read(y); // этаж егора
read(t1); // скорость маша
read(t2); // скорость лифта
read(t3); // двери лифта
read(z); // этаж лифта

if abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('YES') else write('NO');

end.

var x,y,t1,t2,t3,z : integer;
begin
read(x); // Этаж маши
read(y); // этаж егора
read(t1); // скорость маша
read(t2); // скорость лифта
read(t3); // двери лифта
read(z); // этаж лифта

if abs(x-y)*t1 > abs(x-z)*t2+2*t3+abs(x-y)*t2+t3 then write('NO') else write('YES');

end.

program xxx;
var x,y,z,t1,t2,t3,v1,v2:integer;

begin

read(x,y,z,t1,t2,t3);

v1:=abs(z-x)*t2+abs(y-x)*t2+2*t3;
v2:=abs(y-x)*t1;

if v1>v2 then

writeln('NO')

else

writeln('YES');

end.

var
 x, y, z, t1, t2, t3, tl, tp: integer;
begin
 read(x, y, z, t1, t2, t3);
 tl := abs((x - z))*t2 + t3 + abs((x - y))*t2 + t3;
 tp := abs((x - z))*t1;
 if tl <= tp then writeln('YES')
 else writeln('NO');

end.

var
 x, y, z, t1, t2, t3, tl, tp: integer;
begin
 read(x, y, z, t1, t2, t3);
 tl := (x - z)*t2 + t3 + (x - y)*t2 + t3;
 tp := (x - z)*t1;
 if tl <= tp then writeln('YES')
 else writeln('NO');

end.

var
 x, y, z, t1, t2, t3, tl, tp: integer;
begin
 read(x, y, z, t1, t2, t3);
 tl := abs((x - z))*t2 + t3 + abs((x - y))*t2 + t3;
 tp := abs((x - y))*t1;
 if tl <= tp then writeln('YES')
 else writeln('NO');

end.

Var x,y,z,t1,t2,t3,k,s1,s2:int64;
Begin
Read(x,y,z,t1,t2,t3);
k:=abs(y-x);
s1:=k*t1;
s2:=abs(z-x)*t2+k*t2+2*t3;
If (s1>=s2) then Writeln ('YES')
else Writeln ('NO');
end.

Var x,y,z,t1,t2,t3,time1,time2:integer;
Begin
Read(x,y,z,t1,t2,t3);
time1:=abs(y-x)*t1;
time2:=((abs(z-x))*t2)+((abs(y-x))*t2)+(t3*3);
If time1>time2 then writeln('YES')
else writeln('NO');
end.

Var
    x, y, z, t1, t2, t3: LongInt;

Begin
    Read(x, y, z, t1, t2, t3);
    If (abs(x - y))*t1 <= (abs(x - z) + abs(y - x))*t2 + 3*t3 then
        Write('NO')
    Else
        Write('YES')
End.

Var
    x, y, z, t1, t2, t3: UInt64;

Begin
    Read(x, y, z, t1, t2, t3);
    If (abs(x - y))*t1 < (abs(x - z) + abs(y - x))*t2 + 2*t3 then
        Write('NO')
    Else
        Write('YES')
End.

program nA;
var
  x,y,z,t1,t2,t3,t4,a,b,c,d:integer;
begin
  read(x,y,z,t1,t2,t3);
  if z <> x then
  begin
   a:=abs(z-x);
   t4:=t2*a;
  end;
  b:=abs(x-y);
  c:=4*t3+t2*b+t4;
  d:=b*t1;
  if c>d then
   write('NO')
  else
   write('YES');
end.

program nA;
var
  x,y,z,t1,t2,t3,t4,a,b,c,d:integer;
begin
  read(x,y,z,t1,t2,t3);
  if z <> x then
  begin
   a:=abs(z-x);
   t4:=t2*a;
  end;
  b:=abs(x-y);
  c:=4*t3+t2*b+t4;
  d:=b*t1;
  if c>=d then
   write('NO')
  else
   write('YES');
end.

program nA;
var
  x,y,z,t1,t2,t3,t4,a,b,c,d:integer;
begin
  read(x,y,z,t1,t2,t3);
  if z <> x then
  begin
   a:=abs(z-x);
   t4:=t2*a;
  end;
  b:=abs(x-y);
  c:=2*t3+t2*b+t4;
  d:=b*t1;
  if c>=d then
   write('NO')
  else
   write('YES');
end.

var x, y, z, t1, t2, t3, out:integer;

begin
  readln(x, y, z, t1, t2, t3);
  if (abs(z-x))*t2+t3+(abs(y-x))*t2+t3 <= (abs(y-x))*t1 then
    write('YES')
  else
    write('NO');
end.

Program p;
var x, y, z, t1, t2, t3, res: integer;

begin
read(x, y, z, t1, t2, t3);
res+=t3*2;
res+=(abs(x-y)+abs(x-z))*t2;
if res<=abs(x-y)*t1 then write('YES')
  else write('NO')
end.

Program p;
var x, y, z, t1, t2, t3: integer;

begin
read(x, y, z, t1, t2, t3);
if t3*2+(abs(x-y)+abs(x-z))*t2<=abs(x-y)*t1 then write('YES')
  else write('NO')
end.

program HelloWorld;
var x,y,z,t1,t2,t3,tpod,tles,etag,etagl:integer;
begin
   read(x,y,z,t1,t2,t3);
   if x> y then etag:=x-y else etag:=y-x;
   if x> z then etagl:=x-z else etagl:=z-x;
   tpod:=t3*2+t2*(etagl+etag);
   tles:=t1*etag;
   if tpod <= tles then write('YES')else write('NO');
   end.

program HelloWorld;
var x,y,z,t1,t2,t3,tpod,tles,etag:integer;
begin
   read(x,y,z,t1,t2,t3);
   if x> y then etag:=x-y else etag:=y-x;
   tpod:=t3*2+t2*etag;
   tles:=t1*etag;
   if tles < tpod then write('NO')else write('YES');
   end.

program HelloWorld;
var x,y,z,t1,t2,t3,tpod,tles,etag,etagl:integer;
begin
   read(x,y,z,t1,t2,t3);
   if x> y then etag:=x-y else etag:=y-x;
   if x> z then etagl:=x-z else etagl:=z-x;
   tpod:=t3*2+t2*(etagl+etag);
   tles:=t1*etag;
   if tles < tpod then write('NO')else write('YES');
   end.

var x,y,z,t1,t2,t3:integer;
begin
readln(x,y,z,t1,t2,t3);
if (x>y) and (x>z) then begin
if (((x-z)*t2+t3+t3+(x-y)*t2+t3)<((x-y)*t1))
   or
   (((x-z)*t2+t3+t3+(x-y)*t2+t3)=((x-y)*t1))
     then writeln('YES') else writeln('NO');end;

if (x<y) and (x>z) then begin
if (((x-z)*t2+t3+t3+(y-x)*t2+t3)<((y-x)*t1))
   or
   (((x-z)*t2+t3+t3+(y-x)*t2+t3)=((y-x)*t1))
     then writeln('YES') else writeln('NO');end;

if (x>y) and (x<z) then begin
if (((z-x)*t2+t3+t3+(x-y)*t2+t3)<((x-y)*t1))
   or
   (((z-x)*t2+t3+t3+(x-y)*t2+t3)=((x-y)*t1))
     then writeln('YES') else writeln('NO');end;

if (x<y) and (x<z) then begin
if (((z-x)*t2+t3+t3+(y-x)*t2+t3)<((y-x)*t1))
   or
   (((z-x)*t2+t3+t3+(x-y)*t2+t3)=((x-y)*t1))
     then writeln('YES') else writeln('NO');end;

end.

var x,y,z,t1,t2,t3:integer;
begin
readln(x,y,z,t1,t2,t3);
if (x>y) and (x>z) then begin
if ((x-z)*t2+t3+t3+(x-y)*t2)<((x-y)*t1) then writeln('YES') else writeln('NO');end;

if (x<y) and (x>z) then begin
if ((x-z)*t2+t3+t3+(y-x)*t2)<((y-x)*t1) then writeln('YES') else writeln('NO');end;

if (x>y) and (x<z) then begin
if ((z-x)*t2+t3+t3+(z-y)*t2)<((x-y)*t1) then writeln('YES') else writeln('NO');end;

if (x<y) and (x<z) then begin
if ((z-x)*t2+t3+t3+(y-x)*t2)<((y-x)*t1) then writeln('YES') else writeln('NO');end;

end.

var x,y,z,t1,t2,t3:integer;
begin
readln(x,y,z,t1,t2,t3);
if (x>y) and (x>z) then begin
if ((x-z)*t2+t3+t3+(x-y)*t2+t3)<((x-y)*t1) then writeln('YES') else writeln('NO');end;

if (x<y) and (x>z) then begin
if ((x-z)*t2+t3+t3+(y-x)*t2+t3)<((y-x)*t1) then writeln('YES') else writeln('NO');end;

if (x>y) and (x<z) then begin
if ((z-x)*t2+t3+t3+(x-y)*t2+t3)<((x-y)*t1) then writeln('YES') else writeln('NO');end;

if (x<y) and (x<z) then begin
if ((z-x)*t2+t3+t3+(y-x)*t2+t3)<((y-x)*t1) then writeln('YES') else writeln('NO');end;

end.

var x,y,z,t1,t2,t3:integer;
begin
readln(x,y,z,t1,t2,t3);
if (x>y) and (x>z) then begin
if ((x-z)*t2+t3+t3+(x-y)*t2)<((x-y)*t1) then writeln('YES') else writeln('NO');end;

if (x<y) and (x>z) then begin
if ((x-z)*t2+t3+t3+(y-x)*t2)<((y-x)*t1) then writeln('YES') else writeln('NO');end;

if (x>y) and (x<z) then begin
if ((z-x)*t2+t3+t3+(x-y)*t2)<((x-y)*t1) then writeln('YES') else writeln('NO');end;

if (x<y) and (x<z) then begin
if ((z-x)*t2+t3+t3+(y-x)*t2)<((y-x)*t1) then writeln('YES') else writeln('NO');end;

end.

var
     le,li,x,y,z,t1,t2,t3: integer;
begin
read(x,y,z,t1,t2,t3);
le:=t1*abs(x-y);
li:=3*t3+t2*abs(z-y)+t2*abs(x-y);
if li>=le then write('yes') else write('no');
end.

var
     le,li,x,y,z,t1,t2,t3: integer;
begin
read(x,y,z,t1,t2,t3);
le:=t1*abs(x-y);
li:=3*t3+t2*abs(z-x)+t2*abs(x-y);
if li<=le then write('yes ',li,' ',le) else write('no ',li,' ',le);
end.


Vasya has a pile, that consists of some number of stones. $$$n$$$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.You are given $$$n$$$ operations which Vasya has made. Find the minimal possible number of stones that can be in the pile after making these operations.

The first line contains one positive integer $$$n$$$ — the number of operations, that have been made by Vasya ($$$1 \leq n \leq 100$$$). The next line contains the string $$$s$$$, consisting of $$$n$$$ symbols, equal to "-" (without quotes) or "+" (without quotes). If Vasya took the stone on $$$i$$$-th operation, $$$s_i$$$ is equal to "-" (without quotes), if added, $$$s_i$$$ is equal to "+" (without quotes).

Print one integer — the minimal possible number of stones that can be in the pile after these $$$n$$$ operations.

NoteIn the first test, if Vasya had $$$3$$$ stones in the pile at the beginning, after making operations the number of stones will be equal to $$$0$$$. It is impossible to have less number of piles, so the answer is $$$0$$$. Please notice, that the number of stones at the beginning can't be less, than $$$3$$$, because in this case, Vasya won't be able to take a stone on some operation (the pile will be empty).In the second test, if Vasya had $$$0$$$ stones in the pile at the beginning, after making operations the number of stones will be equal to $$$4$$$. It is impossible to have less number of piles because after making $$$4$$$ operations the number of stones in the pile increases on $$$4$$$ stones. So, the answer is $$$4$$$.In the third test, if Vasya had $$$1$$$ stone in the pile at the beginning, after making operations the number of stones will be equal to $$$1$$$. It can be proved, that it is impossible to have less number of stones after making the operations.In the fourth test, if Vasya had $$$0$$$ stones in the pile at the beginning, after making operations the number of stones will be equal to $$$3$$$.

var x:char;
z,i,n:longint;
begin
readln(n);
z:=0;
for i:=1 to n do
begin
read(x);
if  (z=0) and (x='-') then z:=0;
if (z>0) and (x='-') then dec(z);
if x='+' then inc(z);
end;
if z<=0 then write(0) else write(z);
end.

Program Apileofstones;
uses math;
var n,d:byte; i:longint; s:string;
begin   //assign(input,'1159A.inp'); reset(input);
        //assign(output,'1159A.out'); rewrite(output);
        readln(n); readln(s);
        d:=0;
        for i:=1 to length(s) do
        if s[i]='+' then inc(d)
        else if d>=1 then dec(d);
        writeln(d);
        //close(input); close(output);
end.

program a;

var
   n, min, sum : integer;
   s           : string;
   c           : char;

begin
   readln(n);
   readln(s);
   min := 0;
   sum := 0;
   for c in s do
      begin
         if c = '+' then
            inc (sum)
         else if c = '-' then
            dec(sum);
         if sum < min then
            min := sum;
      end;
   writeln(sum - min);
end.

var i,j,k,t:longint;
var a,b,c,d,e,sohieu,bd,kt,mi,m,c1,l1,c2,l2,ans,n,mints,maxts,tans:longint;
var ch:char;
var f1,f2:text;
var s:string;
var ar,er,gr,mr,lar,rar:array[1..200000] of longint;

begin
        readln(n);
        for i:=1 to n do
        begin
                read(ch);
                if(ch='-') and (ans=0)then continue;
                if(ch='-') and (ans>0)then ans:=ans-1;
                if(ch='+')then inc(ans);

        end;
        writeln(ans);

end.

var
    st:string;
    n1,n,i,max,j:longint;
begin

        readln(n);
        readln(st);

max:=maxlongint;
for j:= 0 to n do
begin
n1:=j;
for i:= 1 to n do
        begin
                if st[i]='+' then if n1<n then n1:=n1+1;
                if st[i]='-' then if n1>0 then n1:=n1-1;
        end;
if n1<max then max:=n1;
end;
write(max);

end.

var a,n,i:longint;q:char;
begin
 readln(n);
 a:=0;
 for i:=1 to n do
 begin
  read(q);
  if q='+' then inc(a) else dec(a);
  if a<0 then a:=0;
 end;
 write(a)
end.

const fi='';
      fo='';
var f:text;
    min,d,s,i,n:longint;
    x:boolean;
    st:ansistring;

begin
  assign(f,fi);reset(f);
  readln(f,n);
  readln(f,st);

  assign(f,fo);rewrite(f);
  x:=false;
  min:=high(longint);
  for i:=1 to n do
        begin
          if st[i]='-' then inc(d);
        end;
  while (true) do
        begin
          s:=d;
          for i:=1 to n do
                begin
                  if s<0 then begin x:=true; break; end;
                  if st[i]='+' then inc(s);
                  if st[i]='-' then dec(s);
                end;
           if (x=true) then break;
           if s<min then min:=s;
          dec(d);
          if s=0 then
          begin
            min:=0;
            break;
          end;
        end;
  writeln(f,min);
  close(f);
end.

var bh,i,n:longint;
st:ansistring;
begin

readln(n);
readln(st);
bh:=0;
for i:=1 to length(st) do if st[i]='+' then inc(bh) else if bh>=1 then dec(bh);
writeln(bh);
readln;
end.

var c:char;
    n,i,j,k,p,a,b:longint;
begin
readln(n);
for i:=1 to n do begin
read(c);
if (c='-') and (a<>0) then dec(a);
if (c='+') then inc(a) end;
write(k+a);
end.

var     i, n, o, stones, kt: longint;
        check: boolean;
        s: string;
        f1, f2: text;
const   fi = '';
        fo = '';
{=================================================}
procedure Input;
begin
        assign(f1, fi); reset(f1);
        readln(f1, n);
        readln(f1, s);
        close(f1);
end;
{=================================================}
procedure Output;
begin
        assign(f2, fo); rewrite(f2);
        check := false;
        while (check = false) do
        begin
          if (kt = 1) then inc(o);
          kt := 0;
          stones := o;
          for i := 1 to n do
          begin
            if (s[i] = '+') then inc(stones)
            else dec(stones);
            if (stones < 0) then
            begin
              kt := 1;
              break;
            end;
          end;
          if (kt = 0) then check := true;
        end;
        writeln(f2, stones);
        close(f2);
end;
{=================================================}
begin
        Input;
        Output;
end.
{=================================================}

var
  s : string;
  n,i,ans : longint;
begin
  readln(n);
  readln(s);
  for i := 1 to length(s) do
    if (s[i] = '-') and (ans > 0) then
      dec(ans)
    else if (s[i] = '+') then
      inc(ans);
  writeln(ans);
end.

program Project1;
var n,br:longint;
a:char;
begin
  br:=0;
  readln(n);
  while n>0 do
begin
  read(a);
  if (a='-') and (br>0) then
   begin
   br:=br-1;
   end;
  if (a='+') then
   begin
   br:=br+1;
   end;
 n:=n-1;
end;
writeln(br);
readln;
end.

uses math;
var
   n, i, cur, stones : longint;
   s : ansistring;

begin
    readln(n); readln(s);
    i := 1;
    stones := 0; cur := 0;
    for i := 1 to n do
    begin
        if (s[i] = '+') then inc(cur) else dec(cur);
        stones := max(stones, max(0, -cur));
    end;
    for i := 1 to n do
    if (s[i] = '+') then inc(stones) else dec(stones);
    writeln(stones);
end.

var n,i,aux:longint;
    s:ansistring;
begin
        readln(n);
        readln(s);
        for i:=1 to length(s) do
        if (s[i]='+') then inc(aux)
        else if (s[i]='-') and (aux>0) then dec(aux);
        writeln(aux);
end.

const
  sz=1000;
var
   i:longint;
  ans, k, n:int64;
  s:ansistring;
begin
  readln(n);
  readln(s);
  for i:=1 to n do
    if s[i]='+' then inc(k)
    else
    if k<>0 then dec(k);
  writeln(k);
end.

var
  s: string;
  n, i, j, k, c: longint;

begin
  readln(n);
  readln(s);
  k := 0; j := 0; c := 0;
  for i := 1 to n do if (s[i] = '-') then inc(c) else break;
  for i := 1 to n do
  begin
    if (s[i] = '-') then c := c - 1 else inc(c);
    if (c < 0) then inc(c);
  end;
  write(c);
end.

var n,i,x:integer;
    s:string;
begin
readln(n);
readln(s);
for i:=1 to n do
 if (s[i]='-') and (x>0) then dec(x) else
 if s[i]='+' then inc(x);
writeln(x)
end.

var n,x,i:integer;
    s:string;

begin
    readln(n);
    readln(s);

    for i:=1 to n do
    begin
        if s[i]='+' then x:=x+1
        else
        if x>0 then x:=x-1;
    end;
    writeln(x);
end.

var
n,pile,i:longint;
a:array[1..100] of char;
begin
  readln(n);
pile:=0;
for i:=1 to n do
begin
  read(a[i]);
if a[i]='+' then inc(pile);
if (a[i]='-') and (pile>0) then dec(pile);
end;
writeln(pile);
end.

const fi='';
      fo='';
var f:text;
    n,i,d:integer;
    st:string;

procedure docf;
begin
        assign(f,fi);
        reset(f);
        readln(f,n);
        read(f,st);
        close(f);
end;

procedure ghif;
begin
        assign(f,fo);
        rewrite(f);
        d:=0;
        for i:= 1 to n do
        begin
                if st[i]='+' then inc(d) else dec(d);
                if d<0 then d:=0;
        end;
        write(f,d);
        close(f);
end;

begin
        docf;
        ghif;
end.

uses math;
var a:longint;c:char;
begin
  readln;
  while not eoln do
  begin
    read(c);
    if c='+' then inc(a)
    else a:=max(0,a-1);
  end;
  writeln(a);
end.

var mini, ans: longint;
    n, i: longint;
    c: char;
begin
    readln(n);
    for i := 1 to n do
    begin
        read(c);
        if c = '+' then ans := ans + 1
        else
        begin
            ans := ans - 1;
            if mini > ans then mini := ans;
        end;
    end;
    write(ans - mini);
end.

var
	a, b, n, c, c1, m, x, x1, x2, x3: integer;
	s: string;
	arr, arr1: array[0..100] of integer;

begin
	{$string_nullbased+}

	readln(n);
	readln(s);
	for var i := 0 to s.length - 1 do
	begin
		if (s[i] = '+') then
			a += 1
		else
			if (a > 0) then
				a -= 1;
	end;

	writeln(a);

end.

var
n, x, i:integer;
s:string;

begin
readln(n);
readln(s);

for i:=1 to n do
if s[i]='+' then x:=x+1
else
if x>0 then x:=x-1;

writeln(x);

end.

var n,ans,i:integer;s:string;
Begin
  readln(n);
  readln(s);
  ans:=0;
  for i:= 1 to n do
  begin
    if(s[i]='+') then
      inc(ans)
    else
      dec(ans);
    if (ans<0) then
      ans:=0;
  end;
  writeln(ans);
end.

var s:string;i,n,m,p,k,j,m1:integer;
begin readln(n);
readln(s);k:=0;i:=1;
m:=0;p:=0;m1:=0;
s:=s+' ';
for j:=1 to n do begin
if s[j]='+' then k:=k+1
            else k:=k-1;
if k<0 then k:=k+1
                      end;
 write(k)

end.

Var
    n, Ans: Integer;
    S: String;

Begin
    Readln(n);
    Readln(S);
    For Var i := 1 to n do
        If S[i] = '+' then
            Ans += 1
        Else If (S[i] = '-') and (Ans > 0) then
            Ans -= 1;
    Write(Ans)
End.

Program ILoveYou;
VAR n,i,plus,minus,aux:int64; a:array[1..101] of char;
Begin

Readln(n);
for i:=1 to n do
Begin
Read(a[i]);
end;

aux:=0;
for i:=1 to n do
Begin
if (a[i] = '-') then aux:=aux - 1 else aux:=aux + 1;
if (aux < 0) then aux:=0;
end;

Writeln(aux);

Readln;
END.

var
  n, i, b: integer;
  s: string;

begin
  readln(n);
  readln(s);
  for i := 1 to length(s) do
  begin
    if s[i] = '-' then
    begin
      if b > 0 then
        b := b - 1
      else
        b := 0;
    end
    else
      b := b + 1;
  end;
  write(b);
end.

var s:string;n,i,k:integer;
begin
readln(n);
readln(s);
k:=0;
for i:=1 to n do
  if s[i]='+' then k:=k+1 else begin k:=k-1;
if k<0 then k:=0;end;
write(k);
end.

Var tmp , n , i , kq , j : Longint;
    s : string;
    kt : Boolean;
    A : Array [1..100] of Longint;

Begin
Readln(n); Readln(s);
For i := 1 to n do
    Begin
    If S[i] = '+' then Inc(A[i]) else Dec(A[i]);
    End;
For i := 0 to n do
    Begin
    kt := True; tmp := i;
    For j := 1 to n do
        Begin
        Inc(tmp , A[j]);
        If tmp < 0 then kt := False;
        If not kt then Break;
        End;
    If kt then Break;
    End;
Write(tmp);
End.

program Project_A;

var
  n, i, ans: longint;
  c: char;

begin
  readln(n);
  ans := 0;
  for i := 1 to n do begin
    read(c);
    if c = '-' then
      dec(ans)
    else
      inc(ans);
    if ans < 0 then
      ans := 0;
  end;

  write(ans);
end.

                             const eps=1e-10;
      besk=8000000000000000000; label 1,3,2,44;
type mas=array[-10000..1200000+1] of int64; integer=longint;
var mask,ii,jj,i1,j1,ppp,tt,start,qq,kol1,dl,p0,stepp,h,n2,i,j,k,l,m,step,k1,w,mesto,num:longint;
ss,ss1:string;
p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;
  nommaxpref,nommaxsuff,maxpref,maxsuff,nomsuff,llsuff,rrsuff,nompref,llpref,rrpref,ll,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;
 jmax,maxx, gr,grr,ener,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..2000000] of string;
  newpole,newpole1,pole1,pole:array[-100..1400,-1..1400] of char;
  pred,sled,poss,nabor:array[-10..29,-10..10000] of int64;
  pos:int64;
  ch:char;
  flagg1:boolean;
  kol,str,place,sum,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..1200000] 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])or(a[i]=a[j])and(a1[i]=a1[j])and(a2[i]<a2[j])or(i<=p)and(j>p)  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
  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 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;

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;

function maxdl(pos:longint):longint;
var ll,rr,i,j,poss,ot:longint;
begin

 maxdl:=ot;
end;

begin

  { assign (input,'D:\Projects\input.txt');reset(input);
   assign (output,'D:\Projects\output.txt'); rewrite(output);
   }
   readln(n); readln(ss);
   for i:=1 to n do if ss[i]='+' then x[i]:=x[i-1]+1 else x[i]:=x[i-1]-1;

   p1:=10000000;
   p2:=-10000000;
   for i:=0 to n do p1:=min(p1,x[i]);
   for i:=0 to n do p2:=max(p2,x[i]);

 { writeln(p1,' ',p2,'  ',x[n]-p1);
 } writeln(x[n]-p1);

 1: close (output);
     end.

program a___________________________________________code;

{$APPTYPE CONSOLE}

   var i,j,n,res,km,kp,start,poch:longint;
       s:string;
begin
   readln(n);
   readln(s);
   km:=0;
   kp:=0;
   start:=0;
   for i:=1 to n do
      if s[i]='-' then inc(start) else break;
   poch:=i;                                  //     writeln('poch111=',poch);  // readln;
   if poch>n then writeln(0) else
      begin
         km:=0;
         kp:=0;                            //     writeln('start=',start);    writeln('poch=',poch);
         while poch<=n do
            begin
               while s[poch]='+' do
                  begin
                     inc(kp);
                     inc(poch)
                  end;                               //    writeln('kp=',kp);     writeln('poch111=',poch);      // readln;
               if poch>n then break;
               while s[poch]='-' do
                  begin
                     inc(km);
                     inc(poch)
                  end;                               //       writeln('km=',km);     writeln('poch=',poch);
               if km>kp then
                   begin
                       start:=start+abs(km-kp);
                       kp:=0
                   end else kp:=kp-km;            //    ;writeln('start=',start);    writeln('poch=',poch);
               km:=0;
               if poch>n then break
            end;                     //   writeln('start=',start);
         for i:=1 to n do
           if s[i]='-' then dec(start) else inc(start);
         writeln(start)
      end; readln
end.

var
    st:string;
    n1,n,i:longint;
begin

        readln(n);
        readln(st);

n1:=n;
for i:= 1 to n do
        begin
                if st[i]='+' then if n1<n then n1:=n1+1;
                if st[i]='-' then if n1>0 then n1:=n1-1;
        end;
write(n1);

end.

var
    st:string;
    n1,n,i,max,j:longint;
begin

        readln(n);
        readln(st);

max:=maxlongint;
for j:= 1 to n do
begin
n1:=j;
for i:= 1 to n do
        begin
                if st[i]='+' then if n1<n then n1:=n1+1;
                if st[i]='-' then if n1>0 then n1:=n1-1;
        end;
if n1<max then max:=n1;
end;
write(max);

end.

uses math;
var
   n, i, j, plus, minus, stones : longint;
   s : ansistring;

begin
    readln(n); readln(s);
    i := 1; j := 1;
    stones := 0;
    plus := 0;
    while (i <= n) do
    begin
        while (j <= n) and (s[i] = s[j]) do inc(j);
        if (s[i] = '-') then
        begin
            stones := max(stones, max(0, j - i - plus));
            plus := plus - min(plus, j - i);
        end
        else plus := plus + j - i;
        i := j;
    end;
    for i := 1 to n do
    if (s[i] = '+') then inc(stones) else dec(stones);
    writeln(stones);
end.

uses math;
var
   n, i, cur, stones : longint;
   s : ansistring;

begin
    readln(n); readln(s);
    i := 1;
    stones := 0; cur := 0;
    for i := 1 to n do
    if (s[i] = '+') then inc(cur) else dec(cur);
    stones := -min(0, cur);
    for i := 1 to n do
    if (s[i] = '+') then inc(stones) else dec(stones);
    writeln(stones);
end.

var n,i,pl,min:longint;
    s:ansistring;
begin
        readln(n);
        readln(s);
        for i:=1 to length(s) do
        if (s[i]='+') then inc(pl) else inc(min);
        if (pl>min) then writeln(pl-min)
        else if (pl=min) then writeln(pl)
        else if (pl<min) then writeln(0);
end.

var
  s: string;
  n, i, j, k, c: longint;

begin
  readln(n);
  readln(s);
  k := 0; j := 0; c := 0;
  for i := 1 to n do if (s[i] = '-') then inc(c) else break;
  for i := c+1 to n do if (s[i] = '+') then inc(k) else inc(j);
  if (k > j) then write(k-j) else write(0);

end.

var
  s: string;
  n, i, j, k, c: longint;

begin
  readln(n);
  readln(s);
  k := 0;
  for i := 1 to n do if (s[i] = '-') then inc(c) else break;
  for i := 1 to n do
    if (s[i] = '-') then c := c - 1 else inc(c);
  if (c < 0) then write(0) else write(c);
end.

var
  s: string;
  n, i, j, k, c: longint;

begin
  readln(n);
  readln(s);
  k := 0;
  for i := 1 to n do if (s[i] = '-') then inc(c) else break;
  for i := 1 to n do
    if (s[i] = '-') then c := c - 1 else inc(c);
  write(c);
end.

var w,i,p,n:integer;
    a:array[1..10000] of char;
begin
        readln(n);
        for i:=1 to n do
        begin
                read(a[i]);
                if a[i]='+' then inc(p)
        end;
        if p>=(n-p) then
        begin
                w:=0;
                for i:=1 to n do
                begin
                        if a[i]='+' then inc(w)
                        else if w>0 then dec(w);
                end;
                write(w);
                halt;
        end
        else
        begin
                w:=n;
                for i:=1 to n do
                begin
                        if a[i]='+' then inc(w)
                        else if w>0 then dec(w);
                end;
                write(w);
                halt;
        end;
end.

var w,i,p,n:integer;
    a:array[1..10000] of char;
begin
        readln(n);
        for i:=1 to n do
        begin
                read(a[i]);
                if a[i]='+' then inc(p)
        end;
        if p>(n-p) then
        begin
                w:=0;
                for i:=1 to n do
                begin
                        if a[i]='+' then inc(w)
                        else dec(w);
                end;
                write(w);
                halt;
        end
        else
        begin
                w:=n;
                for i:=1 to n do
                begin
                        if a[i]='+' then inc(w)
                        else dec(w);
                end;
                write(w);
                halt;
        end;
end.

var s:string;i,n,m,p,k,j,m1:integer;
begin readln(n);
readln(s);k:=0;i:=1;
m:=0;p:=0;m1:=0;
s:=s+' ';
for j:=1 to n do begin
if s[j]='+' then p:=p+1
else m:=m+1;
                      end;
while s[i]='-' do begin k:=k+1; i:=i+1 end;
writeln(p,' ',m);
if s[1]='-' then write(k+p)
else
if p-m<0 then write(abs(p-m)) else write(p-m);

end.

var s:string;i,n,m,p,k,j,m1:integer;
begin readln(n);
readln(s);k:=0;i:=1;
m:=0;p:=0;m1:=0;
s:=s+' ';
for j:=1 to n do begin
if s[j]='+' then p:=p+1
else m:=m+1;
                      end;
while s[i]='-' do begin k:=k+1; i:=i+1 end;

if s[1]='-' then write(k+p)
else
if p-m<0 then write(abs(p-m)) else write(p-m);

end.

var s:string;i,n,m,p,k,j,m1:integer;
begin readln(n);
readln(s);k:=0;i:=1;
m:=0;p:=0;m1:=0;
s:=s+' ';
for j:=1 to n do begin
if s[j]='+' then p:=p+1
else m:=m+1;
                      end;
while s[i]='-' do begin k:=k+1; i:=i+1 end;

if s[1]='-' then write(k+p-m)
else
if p-m<0 then write(abs(p-m)) else write(p-m);

end.

Program ILoveYou;
VAR n,i,plus,minus,aux:int64; a:array[1..101] of char;
Begin

Readln(n);
for i:=1 to n do
Begin
Read(a[i]);
end;

i:=n;
while (i > 0) and (a[i] <> '-') do
Begin
i:=i - 1;
end;

aux:=i;
for i:=aux downto 1 do
Begin
if (a[i] = '-') then minus:=minus + 1 else plus:=plus + 1;
end;

if (minus > plus) then Writeln(n - aux) else Writeln(plus - minus + n - aux);

Readln;
END.

Program ILoveYou;
VAR n,i,plus,minus,aux:int64; a:array[1..101] of char;
Begin

Readln(n);
for i:=1 to n do
Begin
Read(a[i]);
end;

i:=1;
while (i <= n) and (a[i] = '-') do
Begin
i:=i + 1;
end;

aux:=i;
for i:=aux to n do
Begin
if (a[i] = '-') then minus:=minus + 1 else plus:=plus + 1;
end;

if (minus > plus) then Writeln('0') else Writeln(plus - minus);

Readln;
END.


Let's write all the positive integer numbers one after another from $$$1$$$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...Your task is to print the $$$k$$$-th digit of this sequence.

The first and only line contains integer $$$k$$$ ($$$1 \le k \le 10000$$$) — the position to process ($$$1$$$-based index).

Print the $$$k$$$-th digit of the resulting infinite sequence.

var k: integer;
      s: string;
begin
   read(k);
   for i: integer := 1 to k do
   s:= s + inttostr(i);
   write(s[k]);
end.

var
i,k:integer;
s:string;
begin
for i:=1 to 10000 do
s:=s+inttostr(i);
read(k);
write(s[k]);
end.

var s : string;

begin
  var count: longint;
  read(count);
  for i: integer := 1 to count do s := s + i.ToString;

  write(s[count]);
end.

var
  k, x, y: int64;

function pow(x, y: int64): int64;
var
  i: longint;
  ans: int64;
begin
  ans := 1;
  for i := 1 to y do
    ans := ans * x;
  result := ans;
end;

begin
  read(k);
  x := 9;
  y := 1;
  while k > x * y do begin
    k := k - x * y;
    x := x * 10;
    inc(y);
  end;
  x := (k - 1) div y + pow(10, y - 1);
  k := k - (x - pow(10, y - 1)) * y;
  write((x div pow(10, y - k)) mod 10);
end.

                                          const eps=1e-10;
      besk=4000000000000000000; label 1,3,2,44;
type mas=array[-10000..550000+1] of int64; integer=longint;
var len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,w,mesto,num:longint;
ss,ss1:string;
dl,dx,dy,ll,rr,sum,m,start,finish,time,p3,p4,jj,qqq,ii,tt,pmax,pmax2,qq,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,t1,n1,t2,q,t,p:int64; flag1:boolean;
  pos,summ,place,kol,str,a2,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean;  pl:longint;
 razr,jmax,maxx, gr,grr,ener,dob,aa,bb,cc,dist,tt3,tt1,tt2,ugg,aa1,aa2,r,ug:int64;
  marked,zan:array[-10..1000000] of boolean;
  predok,a1,b1,strok:array[-10..550000] of int64;
  stroka:array[-1000..1000000] of char;
  ot1,otmax,v:extended;
  sp,sss:array[-10..2000000] of string;
  newpole,dd,pole:array[-100..1210,-1..1210] of int64;
  dchet,dnech,poschet,posnechet:array[-10..290000,-1..30] of int64;
  poss:int64;
  ch:char;
  flagg1:boolean;
  ymax,ymin,xmax,xmin,znach,z,nomer,newplace,newstr,s,next,prev,xx,yy,aold,x,y:array[-100000..2000002] of int64;
  ddd: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])or(a[i]=a[j])and(a1[i]=a1[j])and(a2[i]<a2[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
  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 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;

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 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;

function prost(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;

 prost:=fl;

end;

procedure swap(ii,jj:longint);
var tt,pp:int64;
begin
  tt:=a[ii]; a[ii]:=a[jj]; a[jj]:=tt;
  pp:=pos[a[ii]]; pos[a[ii]]:=pos[a[jj]]; pos[a[jj]]:=pp;

end;

begin

  { assign (input,'D:\Projects\input.txt');reset(input);
   assign (output,'D:\Projects\output.txt'); rewrite(output);
   }

   read(pp);
   t:=9; dl:=1;
   while sum<=pp do
     begin
        sum:=sum+t*dl;
        inc(dl);
        t:=t*10;
     end;
     dec(dl);
     sum:=sum-t div 10*(dl);
    { writeln(sum,' ',dl,' t= ',t);
    } tt:=(pp-sum+dl-1) div dl+t div 90-1;
     razr:=(pp-sum) mod dl;
     if razr=0 then razr:=dl;
    { writeln('chislo= ',tt,' razr= ',razr);
    } for i:=1 to dl do begin  x[dl-i+1]:=tt mod 10; tt:=tt div 10;  end;

     writeln(x[razr]);

 1: close (output);
     end.

Program DigitsSequence(Easy);
uses math;
var S,a:ansistring; i,k:longint;
Procedure Generator;
begin   S:=''; i:=1;
        while length(S)<=10000 do
        begin   str(i,a);
                S:=S+a;
                inc(i);
        end;
end;
begin   //assign(input,'1177A.inp'); reset(input);
        //assign(output,'1177A.out'); rewrite(output);
        readln(k);
        Generator;
        writeln(S[k]);
        //close(input); close(output);
end.

var i,n,d,d1,k:qword;
    s : string;
begin
     readln(n);
     if n<10 then
     writeln(n)
     else
     begin
          d:=10;
          d1:=100;

          k:=2;
          n:=n-9;
          while n>k*9*d do
          begin
               n:=n-k*9*d;
               inc(k);
              // d1:=d1*10;
               d:=d*10;
          end;
          i:=d;
          n:=n-1;
          i:=i+n div k;
          str(i,s);
          writeln(s[n mod k +1]);
     end;
end.

program aziz;
uses wincrt;
    var
k:integer;
    procedure remplir(var k:integer);
		var
		i:integer;
		x:integer;
		ch1,ch:string;
        begin
repeat
readln(k);
until (k>=1) and (k<=10000);
			ch:='';
			for i:=1 to k do
				begin
				str(i,ch1);
			ch:=ch+ch1;
        end;
val(ch[k],x);
writeln(x);
end;
begin
remplir(k);
end.

var
  n,k,l,g,h,z,i : longint;

  function rec(i,j,z : longint):longint;
  var
    f,r,t: longint;
  begin
    f:=1; r:=i;
    for f:=1 to z-j do r:=r div 10;
    r:=r mod 10;
    rec:=r;
  end;

begin
  h:=9; z:=1; g:=0;
  readln(n);
  i:=0; l:=0;
  if n=1 then
    begin
      writeln(1);
      exit;
    end;
  while true do
    begin
      if g=h then
        begin
          h:=h*10;
          g:=0;
          z:=z+1;
        end;
      i:=i+1;
      g:=g+1;
      l:=l+z;
      if l>=n then
        begin
          k:=rec(i,n-(l-z),z);
          break;
        end;
    end;
  writeln(k);
end.

const fi='';
      fo='';
var f:text;
    n,i:longint;
    st,s:ansistring;

begin
  assign(f,fi);reset(f);
  readln(f,n);

  assign(f,fo);rewrite(f);
  for i:=1 to 10000 do
        begin
          str(i,s);
          st:=st+s;
        end;
  writeln(f,st[n]);
  close(f);
end.

program Youssef;
uses wincrt;
var

ch1,ch:string;
k,i:integer;

begin
ch1:='';
readln(k);
for i:=1 to k do
begin
str(i,ch);
ch1:=ch1+ch;
end;
writeln(ch1[k])
end.

uses math;
const fi='SOTHUK.INP';
      fo='SOTHUK.OUT';
var k,result : int64;
procedure inp;
begin
    //    assign(input,fi);reset(input);
        readln(k);//close(input);
end;

procedure main(k : int64);
var temp,mid,tt: int64;
a,b,t : int64;
begin
        temp := k*9 - 1;
        a := trunc(log10(temp));
        t := 1;
        repeat
                mid := (a+t) shr 1;
                tt := trunc(power(10,mid+1));
                b := 9*(mid-1) + 8;
                if power(10,mid)*b > temp then a := mid - 1 else
                        if power(10,mid)*b<=temp then t :=  mid + 1;
                if (power(10,mid)*b > temp) and ((power(10,mid-1)*(9*(mid-2)+8)) < temp) then break;
        until t>a;
        a := a + 1;
        k := k - trunc((power(10,a-1)*(9*(a-2)+8)+1)/9);
        temp := k div a;
        if k mod a <> 0 then b := trunc(power(10,a-1)) + temp else b := trunc(power(10,a-1))+temp-1;
        k := k mod a;
        if k=0 then k := a;
        result := (b div trunc(power(10,a-k))) mod 10;

end;

procedure out;
begin
     //   assigN(output,fo);rewritE(output);
        writeln(result);
        close(output);
end;

begin

        inp;
        main(k);
        out;
end.

var
  k,x,s,a,b,c:int64;
  i:longint;
begin
  readln(k);
  x:=9;s:=1;
  while k>0 do
    begin
      k:=k-x*s;
      x:=x*10;
      inc(s);
    end;
  x:=x div 10;dec(s);k:=k+x*s;
  a:=(k-1) div s;b:=(k-1) mod s+1;c:=1;
  for i:=1 to s-1 do c:=c*10;
  if b=0 then dec(a);c:=c+a;
  for i:=1 to s-b do c:=c div 10;
  writeln(c mod 10);
end.

program pr1;
   var i,k,n:integer;
   x,a:string;
begin
  n:=10000;
  for i:=1 to n do
  begin
    str(i,a);
    x:=x+a;
    end;
    readln(k);
    writeln(x[k]);
    readln;

end.

var st,x :ansistring;
    i,k : longint;
BEGIN
    read(k); st:='';
    for i:=1 to 100001 do
        begin
            str(i,x);
            st:=concat(st,x);
        end;
        write(st[k]);
END.

//type ansistring = string;
var
    k, i: longint;
    posl, st: ansistring;
begin
    read(k);
    posl:='';
    i:=0;
    while length(posl)<k do begin
        i:=i+1;
        str(i, st);
        posl:=posl+st;
    end;
    write(copy(posl, k, 1));
end.

uses math;
var k,kq:qword;
    i:byte;
    st:string;

begin
  //Assign(input,'ds.inp');   reset(input);
  //Assign(output,'ds.out');   rewrite(output);
  read(k);
  if (k>9) then
    begin
      i:=1;
      while (k>9*i*10**(i-1)) do
        begin
          k:=k-9*i*10**(i-1);   inc(i);
        end;
      kq:=k mod i;
      if (kq=0) then str(10**(i-1)+(k div i)-1,st)
      else str(10**(i-1)+(k div i),st);
      if (kq=0) then write(st[length(st)])
      else write(st[kq]);
    end
  else write(k);
end.

var a : array [1..5000] of longint;
    i,n : longint;
    s,ss : string;
begin
  readln(n);
  for i:=1 to 5000 do
     begin
     str(i,s);
     ss:=ss+s;
     end;
  writeln(ss[n]);
end.

var
  i,n:longint;
  ss:string;
  s:ansistring;
begin
  readln(n);
  for i:=1 to 10000 do
  begin
    str(i,ss);
    s:=s+ss;
  end;
  writeln(s[n]);
end.

var k1,k,n:int64;
    i,j:longint;
begin
     readln(n);
     if n<10 then write(n) else
     begin
          n:=n-9;
          k:=1;
          k1:=9;
          for i:=2 to 12 do
          begin
               k:=k*10;
               k1:=k1*10;
               if n>k1*i then n:=n-k1*i else
               begin
                    if n mod i=0 then k:=k+n div i-1
                    else k:=k+n div i;
                    n:=n-n div i*i;
                    if n=0 then n:=i;
                    for j:=0 to i-n-1 do k:=k div 10;
                    k:=k mod 10;
                    write(k);
                    break
               end;
          end;
     end;
     readln
end.

program aziz;
uses wincrt;
    var
k:integer;
    procedure remplir(var k:integer);
		var
		i:integer;
		x:integer;
		ch1,ch:string;
        begin
repeat
writeln('donnez l indice');
readln(k);
until (k>=1) and (k<=10000);
			ch:='';
			for i:=1 to k do
				begin
				str(i,ch1);
			ch:=ch+ch1;
        end;
val(ch[k],x);
writeln(x);
end;
begin
remplir(k);
end.

program aziz;
uses wincrt;
    var
k:integer;
    procedure remplir(var k:integer);
		var
		i:integer;
		ch1,ch:string;
        begin
repeat
writeln('donnez l indice');
readln(k);
until (k>=1) and (k<=10000);
			ch:='';
			for i:=1 to k do
				begin
				str(i,ch1);
			ch:=ch+ch1;
        end;
	writeln(ch[k]);
end;
begin
remplir(k);
end.

var
  n,k,l,g,h,z,i : longint;

  function rec(i,j,z : longint):longint;
  var
    f,r,t: longint;
  begin
    f:=1; r:=i;
    for f:=1 to z-j do r:=r div 10;
    r:=r mod 10;
    rec:=r;
  end;

begin
  h:=9; z:=1; g:=0;
  readln(n);
  i:=0; l:=0;
  while true do
    begin
      if g=h then
        begin
          h:=h*10;
          g:=0;
          z:=z+1;
        end;
      i:=i+1;
      g:=g+1;
      l:=l+z;
      if z>=(n-l) then
        begin
          k:=rec(i+1,n-l,z);
          break;
        end;
    end;
  writeln(k);
end.

var
  n,k,l,g,h,z,i : longint;

  function rec(i,j,z : longint):longint;
  var
    f,r,t: longint;
  begin
    f:=1; r:=i;
    for f:=1 to z-j do r:=r div 10;
    r:=r mod 10;
    rec:=r;
  end;

begin
  h:=9; z:=1; g:=0;
  readln(n);
  i:=0; l:=0;
  if n=1 then
    begin
      writeln(1);
      exit;
    end;
  while true do
    begin
      if g=h then
        begin
          h:=h*10;
          g:=0;
          z:=z+1;
        end;
      i:=i+1;
      g:=g+1;
      l:=l+z;
      if z>=(n-l) then
        begin
          k:=rec(i+1,n-l,z);
          break;
        end;
    end;
  writeln(k);
end.

program aziz;
uses wincrt;
    var
k:integer;
    procedure remplir(var k:integer);
		var
		i:integer;
		ch1,ch:string;
        begin
repeat
writeln('donnez l indice');
readln(k);
until (k>1) and (k<10000);
			ch:='';
			for i:=1 to k do
				begin
				str(i,ch1);
			ch:=ch+ch1;
        end;
	writeln(ch[k]);
end;
begin
remplir(k);
end.

var
        tam1,max,cong,so,layso,p:int64;
        chuso:ansistring;
begin
        {Assign(input,'chuso.inp');
        reset(input);
        Assign(output,'chuso.out');
        rewrite(output);}
        read(p);
        str(p,chuso);
        if p<10 then
        begin
                write(p);
                exit;
        end else
        begin
        tam1:=1;
        max:=9;
        cong:=1;
                while p>=max*tam1 do
                begin
                        cong:=cong*10;
                        max:=max*10;
                        inc(tam1);
                end;
        if tam1=2 then
        begin
                p:=p-9;
                so:=p div tam1 +cong;
                layso:=p mod tam1;
                if layso=0 then write((so-1) mod 10) else
                begin
                        str(so,chuso);
                        write(chuso[1]);
                end;
        end else
        begin
                max:=max div 10;
                p:=p-9-max*(tam1-1);
                so:=p div (tam1)+cong;
                layso:=p mod (tam1);
                if layso=0 then write((so-1) mod 10) else
                begin
                        str(so,chuso);
                        write(chuso[1]);
                end;
        end;
        end;
end.

var
        tam1,max,cong,so,layso,p:int64;
        chuso:ansistring;
begin
        {Assign(input,'chuso.inp');
        reset(input);
        Assign(output,'chuso.out');
        rewrite(output);}
        read(p);
        str(p,chuso);
        if p<10 then
        begin
                write(p);
                exit;
        end else
        begin
        tam1:=1;
        max:=9;
        cong:=1;
                while p>=max*tam1 do
                begin
                        cong:=cong*10;
                        max:=max*10;
                        inc(tam1);
                end;
        if tam1=2 then
        begin
                p:=p-9;
                so:=p div tam1 +cong;
                layso:=p mod tam1;
                if layso=0 then write((so-1) mod 10) else
                begin
                        str(so,chuso);
                        write(chuso[1]);
                end;
        end else
        begin
                max:=max div 10;
                p:=p-9-max*(tam1-1);
                so:=p div (tam1)+cong;
                layso:=p mod (tam1);
                if layso=0 then write((so-1) mod 10) else
                begin
                        str(so,chuso);
                        write(chuso[layso]);
                end;
        end;
        end;
end.