const
  tfi = '' ;
  tfo = '' ;
    Nmax=2001 ;
    p=1000000007 ;
var
  fi,fo:text;
  n,m,res :longint;
  f,g,s,ff:array[0..Nmax,0..Nmax]  of longint ;
procedure process;
var
i,j,k:longint ;
begin
  read(fi,m,n) ;
  res := 0 ;
  For i := 1 to m do
   For j := 2 to n do
   begin
    if i = 1 then F[i,j] := 1 else
         F[i,j] := ((int64(j+1)*S[i-1,j]-G[i-1,j]) mod p+p) mod p ;
         S[i,j] := (S[i,j-1] + F[i,j]) mod p ;
         G[i,j] := (G[i,j-1] + int64(F[i,j])*j) mod p ;
   end;
   For i := 1 to m do for j := 1 to n do
    begin
     S[i,j] := (S[i-1,j] + S[i,j]) mod p ;
     G[i,j] := (G[i-1,j] + G[i,j]) mod p ;
    end;
  For i := 1 to m do for j := 2 to n do
   begin
        res := (res + (((int64(j+1)*S[i-1,j] mod p - G[i-1,j]+1) mod p)*((int64(j+1)*S[m-i,j-1] mod p-G[m-i,j-1]+1) mod p) mod p)*(n-j+1)) mod p ;
   end;
  {For i := 1 to m do for j:= 2 to n do if i = 1 then FF[i,j] := 1 else
    begin
     /// FF[i,j] := 1;
      for k := 2 to j do FF[i,j] := (FF[i,j] + FF[i-1,k]*int64(j-k+1)) mod p ;
    end;}
   writeln(fo,(res + p) mod p) ;
end ;
begin
  assign(fi,tfi);reset(fi);
  assign(fo,tfo);rewrite(fo) ;
        process;
  close(fi) ;
  close(fo) ;
end .

uses math;
const
        nmax    =       2010;
        modul   =       1000000007;
var
        n,m:longint;
        res,Sol:int64;
        F,G,H:Array[0..nmax,0..nmax] of longint;
procedure process;
var i,j,u,v:longint;
begin
        read(n,m);
        for i:=1 to n do
            for j:=2 to m do
              begin
                F[i][j]:=(H[i-1][j]*int64(j) - G[i-1][j]+1)mod modul;
                if F[i][j]<0 then F[i][j]:=F[i][j]+modul;
                H[i][j]:=(H[i][j-1]+F[i][j])mod modul;
                G[i][j]:=(G[i][j-1]+F[i][j]*int64(j-1))mod modul;
              end;
        for i:=1 to n do for j:=2 to m do
          begin
            Sol:=(F[i][j]-F[i-1][j])*int64(F[n-i+1][j]);
            Sol:=Sol mod modul;
            if Sol<0 then Sol:=Sol+modul;
            Sol:=(Sol*(m-j+1))mod modul;
            res:=(res+Sol)mod modul;
          end;
        writeln(res);
end;
begin
        assign(input,'');reset(input);
        assign(output,'');rewrite(output);
          process;
        close(input);
        close(output);
end.


var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n*(n-1) div 2 else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				if need > n then break;
				inc(kq,goal2-need+1);
				if need>=n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var n,j,k,m,r,t:int64;
    i:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }
read(n);
m:=5;
while n>=m do m:=m*10;
m:=m div 10;
t:=0;
if m>0 then
  begin
    r:=n div m;
    k:=0;
    for i:=1 to r-1 do
     if i mod 2=1 then
       begin
         k:=k+1;
         t:=t+m*k-1;
       end else t:=t+m*k;
    k:=(r+1) div 2;
    t:=t+(n mod m+1)*k;
    if (n+1) mod (2*m)=0 then t:=t-1;
    write(t);
  end else write(1 shl (n-1)-1-n div 4);
end.

program Project1;

uses
  math;
var
  n, shovels1, shovels2: Int64;
  Max9, sum, add1, add2, With1, WithOut, With1and2, counter: Int64;
  i: LongInt;

procedure Change(var a, b: Int64);
var
  tmp: Int64;
begin
  tmp := b;
  b := a;
  a := tmp;
end;

begin
  ReadLn(n);
  Max9 := 0;
  If n > 9 div 2 then Max9 := 9;
  If n > 99 div 2 then Max9 := 99;
  If n > 999 div 2 then Max9 := 999;
  If n > 9999 div 2 then Max9 := 9999;
  If n > 99999 div 2 then Max9 := 99999;
  If n > 999999 div 2 then Max9 := 999999;
  If n > 9999999 div 2 then Max9 := 9999999;
  If n > 99999999 div 2 then Max9 := 99999999;
  If n > 999999999 div 2 then Max9 := 999999999;
  If n > 9999999999 div 2 then Max9 := 9999999999;
  If Max9 = 0 then
  begin
    Case n of
      2: WriteLn(1);
      3: WriteLn(3);
      4: WriteLn(6);
    end;
  end else
  begin
    shovels1 := n div (Max9+1);
    shovels2 := shovels1;
    add1 := n mod (Max9+1);
    If add1 > Max9 div 2 then
    begin
      add2 := add1 - (Max9 div 2);
      add1 := add1 - add2;
    end;
    With1 := (shovels1+1) * shovels2;
    WithOut := shovels1 * shovels2;
    With1and2 := (shovels1+1) * (shovels2+1);
    If add1 < add2 then
    begin
      Change(add1, add2);
    end;

    counter := Max9 div 2 + 1;
    sum := With1 * (add1 - add2);
    sum := sum + With1and2 * add2;
    counter := counter - add1;
    sum := sum + WithOut * counter;

    WriteLn(sum);
  end;
end.

var i:longint;t,w,s,s1,n,sum,o:int64;
begin
//assign(input,'czxs.in');reset(input);
//assign(output,'czxs.out');rewrite(output);
readln(n);t:=5;
if n<=4 then
  writeln(n*(n-1) div 2)
else
  begin
  while n>=t do
    begin
    w:=w+1;t:=t*10;
    end;
  for i:=1 to w do
    s:=s*10+9;
  s1:=1;
  for i:=1 to w do s1:=s1*10;
  for i:=0 to 8 do
    begin
    o:=s1*i+s;
    if n>=o then
      sum:=sum+o div 2
    else if n>=(o+1) div 2 then
      sum:=sum+n-(o+1) div 2+1
    else break;
    end;
  writeln(sum);
  end;
close(input);close(output);
end.

uses math;
var n,t:int64;
    tmp,res,x:int64;
    i,j:longint;
    pow:array[0..9] of int64;
begin
     //assign(input,'899D.INP');reset(input);
     //assign(output,'899D.out');rewrite(output);
     readln(n);
     if n<=4 then
       begin
            writeln(n*(n-1) div 2);halt;
       end;
     pow[1]:=9;
     for i:=1 to 9 do
        pow[i]:=pow[i-1]*10+9;
     for i:=9 downto 1 do
        begin
             if 2*n-1>=pow[i] then
               begin
                    tmp:=(pow[i]+1) div 2-1;
                    t:=min(tmp,n-tmp);
                    res:=res+t;
                    tmp:=pow[i]+1;x:=pow[i];
                    for j:=1 to 8 do
                       begin
                            x:=x+tmp;
                            if 2*n-1<x then
                              begin
                                   writeln(res);halt;
                              end;
                            t:=(x+1) div 2-1;
                            res:=res+min(t,n-t);
                       end;
                    writeln(Res);halt;
               end;
        end;
     writeln(0);
end.

var n,k,q,m,i:int64;
a:array[0..9] of int64;
s,w:string;
t:integer;
begin
read(n);
if n<5 then
begin
for i:=1 to n-1 do
q+=i;
write(q);
exit;
end;
k:=n+n-1;
str(k,s);
for i:=0 to 9 do
begin
 w:=chr(i+48)+max(1,(s.Length-1))*'9';
if w[1]='0' then delete(w,1,1);
val(w,a[i],t);

end;
if a[9]=n+n-1 then write(1) else
begin
for i:=0 to 8 do
begin

if n>=a[i]-1 then
q+=a[i] div 2 else if (n*2-a[i]+1) div 2>0 then q+=(n*2-a[i]+1) div 2;

end;
write(q)
end
end.

uses
  math;
var
  n,x,t,tmp,p,ans:int64;
  i,d:longint;
begin
  readln(n);
  if n<5 then
    begin
      write(n*(n-1) div 2);
      halt;
    end;
  x:=999999999;
  for i:=9 downto 1 do
    begin
      ans:=0;
      for d:=0 to 8 do
        begin
          t:=d*(10**int64(i))+x;
          tmp:=t-min(t-1,n);
          if tmp<n then
            begin
              p:=(tmp+min(t-1,n)) div 2;
              ans:=ans+p-tmp+1;
            end;
        end;
      if ans>0 then break;
      x:=x div 10;
    end;
  writeln(ans);
end.

program Project1;

uses
  math;
var
  n, shovels1, shovels2: Int64;
  Max9, sum, add1, add2, With1, WithOut, With1and2, counter: Int64;
  i: LongInt;

procedure Change(var a, b: Int64);
var
  tmp: Int64;
begin
  tmp := b;
  b := a;
  a := tmp;
end;

begin
  ReadLn(n);
  Max9 := 0;
  If n > 9 div 2 then Max9 := 9;
  If n > 99 div 2 then Max9 := 99;
  If n > 999 div 2 then Max9 := 999;
  If n > 9999 div 2 then Max9 := 9999;
  If n > 99999 div 2 then Max9 := 99999;
  If n > 999999 div 2 then Max9 := 999999;
  If n > 9999999 div 2 then Max9 := 9999999;
  If n > 99999999 div 2 then Max9 := 99999999;
  If n > 999999999 div 2 then Max9 := 999999999;
  If n > 9999999999 div 2 then Max9 := 9999999999;
  If Max9 = 0 then
  begin
    Case n of
      2: WriteLn(1);
      3: WriteLn(3);
      4: WriteLn(6);
    end;
  end else
  begin
    shovels1 := n div (Max9+1);
    shovels2 := shovels1;
    add1 := n mod (Max9+1);
    If add1 > Max9 div 2 then
    begin
      add2 := add1 - (Max9 div 2);
      add1 := add1 - add2;
    end;
    With1 := (shovels1+1) * shovels2;
    WithOut := shovels1 * shovels2;
    With1and2 := (shovels1+1) * (shovels2+1);
    If add1 < add2 then
    begin
      Change(add1, add2);
    end;

    counter := Max9 div 2 + 1;
    sum := With1 * (add1 - add2);
    sum := sum + With1and2 * add2;
    counter := counter - add1;
    sum := sum + WithOut * counter;
  end;
  WriteLn(sum);
end.

var i:longint;t,w,s,s1,n,sum,o:int64;
begin
//assign(input,'czxs.in');reset(input);
//assign(output,'czxs.out');rewrite(output);
readln(n);t:=5;
while n>=t do
  begin
  w:=w+1;t:=t*10;
  end;
for i:=1 to w do
  s:=s*10+9;
s1:=1;
for i:=1 to w do s1:=s1*10;
for i:=0 to 8 do
  begin
  o:=s1*i+s;
  if n>=o then
    sum:=sum+o div 2
  else if n>=(o+1) div 2 then
    sum:=sum+n-(o+1) div 2+1
  else break;
  end;
writeln(sum);
close(input);close(output);
end.

uses math;
var n,t:int64;
    tmp,res,x:int64;
    i,j:longint;
    pow:array[0..9] of int64;
begin
     //assign(input,'899D.INP');reset(input);
     //assign(output,'899D.out');rewrite(output);
     readln(n);
     if n<=4 then
       begin
            writeln(0);halt;
       end;
     pow[1]:=9;
     for i:=1 to 9 do
        pow[i]:=pow[i-1]*10+9;
     for i:=9 downto 1 do
        begin
             if 2*n-1>=pow[i] then
               begin
                    tmp:=(pow[i]+1) div 2-1;
                    t:=min(tmp,n-tmp);
                    res:=res+t;
                    tmp:=pow[i]+1;x:=pow[i];
                    for j:=1 to 8 do
                       begin
                            x:=x+tmp;
                            if 2*n-1<x then
                              begin
                                   writeln(res);halt;
                              end;
                            t:=(x+1) div 2-1;
                            res:=res+min(t,n-t);
                       end;
                    writeln(Res);halt;
               end;
        end;
     writeln(0);
end.

uses math;
var n,t:int64;
    i,tmp,res,x,j:longint;
    pow:array[0..9] of int64;
begin
     //assign(input,'899D.INP');reset(input);
     //assign(output,'899D.out');rewrite(output);
     readln(n);
     if n<=4 then
       begin
            writeln(0);halt;
       end;
     pow[1]:=9;
     for i:=1 to 9 do
        pow[i]:=pow[i-1]*10+9;
     for i:=9 downto 1 do
        begin
             if 2*n-1>=pow[i] then
               begin
                    tmp:=(pow[i]+1) div 2-1;
                    t:=min(tmp,n-tmp);
                    res:=res+t;
                    tmp:=pow[i]+1;x:=pow[i];
                    for j:=1 to 8 do
                       begin
                            x:=x+tmp;
                            if 2*n-1<x then
                              begin
                                   writeln(res);halt;
                              end;
                            t:=(x+1) div 2-1;
                            res:=res+min(t,n-t);
                       end;
                    writeln(Res);
               end;
        end;
     writeln(0);
end.

uses math;
var n,t:int64;
    i,tmp,res,x,j:longint;
    pow:array[0..9] of int64;
begin
     //assign(input,'899D.INP');reset(input);
     //assign(output,'899D.out');rewrite(output);
     readln(n);
     if n<=4 then
       begin
            writeln(0);halt;
       end;
     pow[1]:=9;
     for i:=1 to 9 do
        pow[i]:=pow[i-1]*10+9;
     for i:=9 downto 1 do
        begin
             if 2*n-1>=pow[i] then
               begin
                    tmp:=(pow[i]+1) div 2-1;
                    t:=min(tmp,n-tmp);
                    res:=res+t;
                    tmp:=pow[i]+1;x:=pow[i];
                    for j:=1 to 8 do
                       begin
                            x:=x+tmp;
                            if 2*n-1<x then
                              begin
                                   writeln(res);halt;
                              end;
                            t:=(x+1) div 2-1;
                            res:=res+min(t,n-t);
                       end;
                    writeln(Res);halt;
               end;
        end;
     writeln(0);
end.

uses math;
var n,t:int64;
    tmp,res,x:int64;
    i,j:longint;
    pow:array[0..9] of int64;
begin
     //assign(input,'899D.INP');reset(input);
     //assign(output,'899D.out');rewrite(output);
     readln(n);
     if n<=4 then
       begin
            writeln(6);halt;
       end;
     pow[1]:=9;
     for i:=1 to 9 do
        pow[i]:=pow[i-1]*10+9;
     for i:=9 downto 1 do
        begin
             if 2*n-1>=pow[i] then
               begin
                    tmp:=(pow[i]+1) div 2-1;
                    t:=min(tmp,n-tmp);
                    res:=res+t;
                    tmp:=pow[i]+1;x:=pow[i];
                    for j:=1 to 8 do
                       begin
                            x:=x+tmp;
                            if 2*n-1<x then
                              begin
                                   writeln(res);halt;
                              end;
                            t:=(x+1) div 2-1;
                            res:=res+min(t,n-t);
                       end;
                    writeln(Res);halt;
               end;
        end;
     writeln(0);
end.

uses
  math;
var
  n,x,t,tmp,p,ans:int64;
  i,d:longint;
begin
  readln(n);
  if n<5 then
    begin
      write(n*(n-1) div 2);
      halt;
    end;
  x:=999999999;
  for i:=9 downto 1 do
    begin
      ans:=0;
      for d:=0 to 8 do
        begin
          t:=d*(10**int64(i))+x;
          tmp:=t-min(t-1,n);
          if tmp<n then
            begin
              p:=(tmp+min(t-1,n)) div 2;
              if odd(n-tmp+1) then dec(p);
              ans:=ans+p-tmp+1;
            end;
        end;
      if ans>0 then break;
      x:=x div 10;
    end;
  writeln(ans);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if goal-1>n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,sum,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;

begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
			sum:=(sum+1) div 2;
			kq:=n-sum+1;
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if goal-1>n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if need>n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				if goal2<=need then break;
				inc(kq,goal2-need+1);
				if need>=n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				if goal2<need then break;
				inc(kq,goal2-need+1);
				if need>=n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
			sum:=(sum+1) div 2;
			kq:=n-sum+1;
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if goal-1>n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
			sum:=(sum+1) div 2;
			kq:=n-sum+1;
			if n = sum then dec(kq);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if goal-1>n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n*(n-1) div 2 else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if need>=n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var	n,tong,dem,vt,n2,kq,i,hs,goal,goal2,need:longint;
	a:array[0..10] of longint;
	sum:int64;
begin
	readln(n);
	tong:=n+n-1;
	sum:=9;
	dem:=0;
	while sum<=tong do
	begin
		inc(dem);
		sum:=sum*10+9;
	end;
	sum:=(sum+1)div 10 - 1;
	if dem=0 then kq:=n else
	begin
		vt:=0;
		n2:=n;
		while n2>0 do
		begin
			inc(vt);
			a[vt]:=n2 mod 10;
			n2:=n2 div 10;
		end;
		kq:=0;
		if dem=vt then
		begin
		    if n = sum then kq:=-1;
			sum:=(sum+1) div 2;
			inc(kq,n-sum+1);
		end
		else
		begin
			hs:=1;
			for i:=2 to vt do
				hs:=hs*10;
			for i:=0 to 9 do
			begin
				goal:=i*hs+sum;
				need:=(goal+1) div 2;
				if goal-1>n then goal2:=n else goal2:=goal-1;
				inc(kq,goal2-need+1);
				if need>=n then break;
			end;
		end;
	end;
	writeln(kq);
end.

var n,j,k,m,r,t:int64;
    i:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }
read(n);
m:=5;
while n>=m do m:=m*10;
m:=m div 10;
t:=0;
if m>0 then
  begin
    r:=n div m;
    k:=0;
    for i:=1 to r-1 do
     if i mod 2=1 then
       begin
         k:=k+1;
         t:=t+m*k-1;
       end else t:=t+m*k;
    k:=(r+1) div 2;
    t:=t+(n mod m+1)*k;
    if (n+1) mod (2*m)=0 then t:=t-1;
    write(t);
  end else write(1 shl (n-1)-1);
end.

var n,j,k,m,r,t:int64;
    i:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);   }
read(n);
m:=5;
while n>=m do m:=m*10;
m:=m div 10;
t:=0;
if m>0 then
  begin
    r:=n div m;
k:=0;
for i:=1 to r-1 do
  if i mod 2=1 then
    begin
      k:=k+1;
      t:=t+(m-1)*k;
    end else t:=t+m*k;
k:=(r+1) div 2;
t:=t+(n mod m+1)*k;
if (n+1) mod (2*m)=0 then t:=t-1;
end;
write(t);
end.

var n,j,k,m,r,t:int64;
    i:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);        }
read(n);
m:=5;
while n>=m do m:=m*10;
m:=m div 10;
t:=0;
if m>0 then
  begin
    r:=n div m;
    k:=0;
    for i:=1 to r-1 do
     if i mod 2=1 then
       begin
         k:=k+1;
         t:=t+(m-1)*k;
       end else t:=t+m*k;
    k:=(r+1) div 2;
    t:=t+(n mod m+1)*k;
    if (n+1) mod (2*m)=0 then t:=t-k;
  end;
write(t);
end.

var n,j,k,m,r,t:int64;
    i:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }
read(n);
m:=5;
while n>=m do m:=m*10;
m:=m div 10;
t:=0;
if m>0 then
  begin
    r:=n div m;
    k:=0;
    for i:=1 to r-1 do
     if i mod 2=1 then
       begin
         k:=k+1;
         t:=t+(m-1)*k;
       end else t:=t+m*k;
    k:=(r+1) div 2;
    t:=t+(n mod m+1)*k;
    if (n+1) mod (2*m)=0 then t:=t-1;
    write(t);
  end else write(1 shl (n-1)-1);
end.

var n,j,k,m,r,t:int64;
    i:longint;
begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output);  }
read(n);
m:=5;
while n>=m do m:=m*10;
m:=m div 10;
t:=0;
if m>0 then
  begin
    r:=n div m;
    k:=0;
    for i:=1 to r-1 do
     if i mod 2=1 then
       begin
         k:=k+1;
         t:=t+(m-1)*k;
       end else t:=t+m*k;
    k:=(r+1) div 2;
    t:=t+(n mod m+1)*k;
    if (n+1) mod (2*m)=0 then t:=t-k;
write(t);
  end else write(1 shl (n-1)-1);
end.

var n,k,q,m,i:int64;
a:array[0..9] of int64;
f:array[0..9] of boolean;
s,w:string;
t:integer;
begin
read(n);
k:=n+n-1;
str(k,s);
for i:=0 to 9 do
begin
 w:=chr(i+48)+max(1,(s.Length-1))*'9';
if w[1]='0' then delete(w,1,1);
val(w,a[i],t);

end;
if a[9]=n+n-1 then write(1) else
begin
for i:=0 to 8 do
begin

if n>=a[i]-1 then
q+=a[i] div 2 else if (n*2-a[i]+1) div 2>0 then q+=(n*2-a[i]+1) div 2;

end;
write(q)
end
end.